CSS Grid Layout implementor (Chromium/Blink & Safari/WebKit)
Member of Igalia Web Platform Team
Tables
Floats
Inlines
CSS Frameworks
CSS Flexible Box
CSS Grid Layout
display: grid;
New formatting context
grid-template-columns
& grid-template-rows
Create boxes from CSS!
<div class="grid">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
<div class="d">D</div>
</div>
grid-column
& grid-row
DOM order ≠ Visual order
<div class="grid">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
</div>
grid-template-areas
### ###### ###### #### #### ### ######## ######## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ## ## ## ## ## ######## ## ######### ## ## ## ## ######### ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ###### ###### #### #### ## ## ## ## ##
<div class="grid">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
<div class="d">D</div>
</div>
grid-auto-flow
<form>
<label>Input</label>
<input>
<label>Checkbox</label>
<input type="checkbox">
<button>Submit form</button>
</form>
CSS Box Alignment spec
Horizontal & vertical centering!
<div class="grid">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
<div class="d">D</div>
</div>
Flexible track sizing
.grid {
display: grid;
grid: 200px 1fr / 100px 1fr auto;
grid-template-areas: "header header"
"aside main "
"aside footer";
}
@media (max-width: 400px) {
.grid {
grid: 1fr / 100px 1fr 100px auto;
grid-template-areas: "header"
"main "
"aside "
"footer"; }
}
<div class="grid">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
</div>
Proposal: reuse column-gap
& introduce row-gap
Fake with alignment
<div class="grid">
<div class="a">A</div>
<div class="b">B</div>
<div class="c">C</div>
</div>
<form><ul>
<li><label>Input</label><input></li>
<li><label>Checkbox</label><input type="checkbox"></li>
<li><button>Submit form</button></li>
</ul></form>
<div class="grid">
<div class="title">Title</div>
<div class="nav">Nav</div>
<div class="main">Lorem ipsum...</div>
<div class="aside">Ad</div>
<div class="aside">Adword</div>
</div>
.grid { display: grid;
width: 400px;
grid-template-columns: 100px 1fr auto;
grid-template-rows: 50px auto; }
.title { grid-row: 1; grid-column: 2; }
.nav { grid-row: 2; grid-column: 1; }
.main { grid-row: 2; grid-column: 2; }
.aside { grid-column: 3; }
100px
is faster than auto
50% faster (20x10 grid)
100% faster (100x20 grid)
150% faster (100x100 grid)
auto
is faster than 1fr
70% faster
stretch
is slower than other (e.g. start
)
20% slower
CSS Grid Layout - http://dev.w3.org/csswg/css-grid/
Started by Microsoft in 2010
Last Working Draft 17 March 2015
W3C Test Suite