Languages

HTML / CSS - how to set cells borders inside grid to have the same width?

3 points
Asked by:
Kenya-Spears
860

I want to add borders of the same width to all cells inside my grid. How can I get rid of multiplying borders?

What I have:

What I want:

I've tried to modify the solution below using box-sizing to have borders of the same width in a whole grid, but it didn't work.

My code:

Note:

The code is based on the following article: HTML - create grid using flexbox 

1 answer
3 points
Answered by:
Admin Dirask Community
4380

There's a simple trick to achieve this:

1. Set border-top and border-left properties of the whole grid.

Set border-top and border-left

2. Set border-right and border-bottom of your cells.

Set border-right and border-bottom

3. The two above together will give you a pretty border.

HTML / CSS - set pretty border for grid

 

Practical example

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join