You are specifying all the red
elements into the fifth row by using grid-row-start: 5
. Yes, the red elements are placed to the fifth row, and that is not immediately visible as you haven't specified an explicit row definition (say using grid-template-rows
).
Implicit Rows
You can define the implicit row definition using something like grid-auto-rows: 50px
and see that the red
element are actually in the fifth row:
ul {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-auto-rows: 50px; /* specify row height */
list-style: none; /* remove bullets */
padding: 0; /* remove default ul padding */
}
.blue {
background-color: blue;
}
.red {
background-color: red;
grid-row-start: 5;
}
li {
border: 1px solid #bbb; /* border for illustration */
}
<ul>
<li class="blue">
<h2>1</h2>
</li>
<li class="red">
<h2>2</h2>
</li>
<li class="blue">
<h2>3</h2>
</li>
<li class="blue">
<h2>4</h2>
</li>
<li class="red">
<h2>5</h2>
</li>
<li class="red">
<h2>6</h2>
</li>
<!-- If you delete this (or any other "red") "li" element then it's working fine -->
<li class="red">
<h2>7</h2>
</li>
<li class="blue">
<h2>8</h2>
</li>
</ul>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…