Initially, we cannot resolve the percentage of the grid-gap since it depends on the height so we ignore it (we consider it as auto
). The browser is first calculating the height considering content like this:
console.log(document.querySelector('.grid').offsetHeight)
.grid {
display: grid;
background-color: blue;
}
.grid-1 {
background-color: red;
opacity:0.5;
}
<div class="grid">
<div class="grid-1">
test
</div>
<div class="grid-1">
test
</div>
<div class="grid-1">
test
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…