I have a CSS grid. Height & width of this grid are same forming a square. Size of each row & column of grid are one-thirds of the size of the height & width respectively. Which would make all the cells square in shape. But they are not square. They seem like it, they are off. Below is screenshot
Let me explain the figure:
- Shows the CSS Grid region, as shown by the inspector it is square in size
- Shows the region formed by all the CSS tracks, we can see that total height of all the columns exceed the height of the actual grid
- Row & Column tracks are sized by fractional spacing
- Height & Width given to the CSS Grid (it is actually 60vmin). Here the computed values are shown. We see both are same, forming a square.
- The computed values of the tracks are shown. Clearly we can see that width of column is not same as height of row. Moreover grid-template-rows details show that height of 2nd row is slightly larger than height of the other 2 rows.
I cannot understand why is this happening. I want to put a bar just below the Grid, but since the apparent height of the grid, exceeds the actual height, the element which should be below the grid gets overlapped with the grid.
* {
box-sizing: border-box;
}
.center-area {
width: 60vmin;
margin-left: auto;
margin-right: auto;
}
.board {
height: 60vmin;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
}
@media screen and (max-width: 600px) {
.board {
height: 90vmin;
}
}
.cell-content-empty {
width: 100%;
height: 100%;
}
.border-holder:nth-child(1) {
border-bottom: 1px solid #808080;
border-right: 1px solid #808080;
}
.border-holder:nth-child(2) {
border-right: 1px solid #808080;
border-bottom: 1px solid #808080;
border-left: 1px solid #808080;
}
.border-holder:nth-child(3) {
border-bottom: 1px solid #808080;
border-left: 1px solid #808080;
}
.border-holder:nth-child(4) {
border-top: 1px solid #808080;
border-right: 1px solid #808080;
border-bottom: 1px solid #808080;
}
.border-holder:nth-child(5) {
border-top: 1px solid #808080;
border-right: 1px solid #808080;
border-bottom: 1px solid #808080;
border-left: 1px solid #808080;
}
.border-holder:nth-child(6) {
border-top: 1px solid #808080;
border-bottom: 1px solid #808080;
border-left: 1px solid #808080;
}
.border-holder:nth-child(7) {
border-top: 1px solid #808080;
border-right: 1px solid #808080;
}
.border-holder:nth-child(8) {
border-top: 1px solid #808080;
border-right: 1px solid #808080;
border-left: 1px solid #808080;
}
.border-holder:nth-child(9) {
border-top: 1px solid #808080;
border-left: 1px solid #808080;
}
<div className="center-area">
<div class="board">
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
<div class="border-holder">
<div class="cell"><img src="https://image.ibb.co/c0q1Ew/transparent.png" alt="" class="cell-content-empty"></div>
</div>
</div>
</div>
