Here is a simple grid (there are a total of twenty .grid_item
s):
<div class="grid">
<h1 class="grid_item">300 px row, 1fr column</h1>
<h1 class="grid_item">300 px row, 1fr column</h1>
<h1 class="grid_item">300 px row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">100 px row, 1fr column </h1>
<h1 class="grid_item">100 px row, 1fr column </h1>
<h1 class="grid_item">100 px row , 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
<h1 class="grid_item">1fr row, 1fr column</h1>
</div>
CSS:
.grid{
display: grid;
grid-template-columns: 1fr 1fr 1fr; /*Entire column is 1fr 1fr 1fr*/
grid-template-rows: 600px 1fr 100px; /*Only first three rowsare 600px 1fr 100px; ?*/
grid-gap: 20px;
}
Note: what I am going to try and explain can be seen here: https://jsfiddle.net/xth3ky0m/3/
When the grid is displayed, every <h1 class = "grid_item"><h1>
is displayed according to grid-template-columns: 1fr 1fr 1fr;
but only the first three rows follow grid-template-rows: 300px 1fr 100px;
. After the first three rows, each row is just 1fr
. The 300px 1fr 100px
row pattern does not automatically repeat like the 1fr 1fr 1fr
column pattern. Why is this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…