Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-grid/grid-definition/grid-auto-fit-collapsed-rows-001.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="match" href="grid-auto-fit-collapsed-rows-001-ref.html">
<meta name="assert" content="Empty auto-fit rows are collapsed to 0px and the gutters on either side of a collapsed row coincide. Flexible rows which remain share the whole definite block size.">
<style>
.grid {
display: grid;
width: 50px;
height: 230px;
margin-bottom: 10px;
background: lightgray;
row-gap: 10px;
grid-template-columns: 50px;
}
.item {
background: green;
}
</style>
<!-- 4 rows fit in 230px. Rows 1 (leading) and 3 (middle) are empty and collapse. -->
<div class="grid" style="grid-template-rows: repeat(auto-fit, 40px)">
<div class="item" style="grid-row: 2"></div>
<div class="item" style="grid-row: 4"></div>
</div>
<!-- 4 rows fit again. 2 items leave 2 rows empty, so the 2 remaining flexible rows share 230px. -->
<div class="grid" style="grid-template-rows: repeat(auto-fit, minmax(40px, 1fr))">
<div class="item"></div>
<div class="item"></div>
</div>