Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why doesn't this CSS grid create the right number of rows and columns?

This CSS grid creates 7 rows only, as you can see by using "Inspect tool" of the browser.
Why?

.grid {
  display: grid;
  grid-gap: 1em;
  height: 100%;
}

.grid8x8 {
  grid-template-rows: repeat(8, 1fr);
  grid-template-columns: repeat(8, 1fr);
}

.element {
  background-color: yellow;
}
<div class="grid grid8x8">
  <div class="element" style="grid-row: 2 / 4; grid-column: 3 / 6;">TEST</div>
</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You have actually 8 rows. What you see with the inspector is the gap between the cells, so for 8 rows there are 7 gaps (red lines are gaps):

enter image description here

If you reduce the gap size, you’ll notice how the rows appear:

enter image description here

Note the 8 rows:

enter image description here

Your problem is the grid cell overflowing all the other cells because there’s not enough space, because your grid-gap is too high.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading