Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8">
<link rel="match" href="grid-auto-fit-implicit-and-spanning-001-ref.html">
<meta name="assert" content="An empty track is one with no in-flow grid item placed in or spanning across it, wherever the explicit grid starts.">
<style>
.grid {
display: grid;
width: 300px;
margin-bottom: 10px;
background: lightgray;
column-gap: 10px;
grid-template-columns: repeat(auto-fit, 50px);
grid-auto-columns: 30px;
}
.item {
height: 50px;
background: green;
}
</style>
<!-- 5 explicit tracks. Line -7 is one track before the explicit grid, so a leading implicit track is created.
Explicit tracks 1 and 2 are empty and collapse, track 3 holds an item, and tracks 4 and 5 collapse. -->
<div class="grid">
<div class="item" style="grid-column: -7"></div>
<div class="item" style="grid-column: 3"></div>
</div>
<!-- The item spans explicit tracks 2 to 4, so none of them collapse. Tracks 1 and 5 do. -->
<div class="grid">
<div class="item" style="grid-column: 2 / 5"></div>
</div>