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-out-of-flow-002.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="match" href="grid-auto-fit-collapsed-out-of-flow-002-ref.html">
<meta name="assert" content="When only collapsed auto-fit tracks follow a grid line, the gutter before them collapses away, so it is not part of the grid area of an absolutely-positioned descendant ending at that line or at the end of the grid.">
<style>
.grid {
display: grid;
position: relative;
width: 300px;
margin-bottom: 10px;
background: lightgray;
column-gap: 10px;
grid-template-columns: repeat(auto-fit, 50px);
}
.item {
height: 50px;
}
.abspos {
position: absolute;
inset: 0;
background: green;
}
</style>
<!-- 5 tracks. Tracks 3, 4 and 5 (trailing) are empty and collapse. -->
<div class="grid">
<div class="item" style="grid-column: 1"></div>
<div class="item" style="grid-column: 2"><div class="abspos" style="grid-column: 2 / 3"></div></div>
</div>
<div class="grid">
<div class="item" style="grid-column: 1"><div class="abspos" style="grid-column: 1 / -1"></div></div>
<div class="item" style="grid-column: 2"></div>
</div>