10. Cost of taming layout
• Hours spent learning non-obvious concepts
• Sacrifice semantics in order to do responsive layout
• Rely on frameworks to work out the numbers
• Extra markup to create grids
• Abstract layout hack with preprocessors (mixins etc.)
14. In-development. Unprefixed support with flag enabled
In-development. Some features supported unprefixed in nightlies
-webkit prefix supported in Webkit Nightlies
IE10 support old syntax with –ms prefix
Is on Edge backlog, marked as High Priority
20. Position item bottom center
B
.grid__item--2 {
grid-column-start: 2;
grid-column-end: 3;
grid-row-start: 2;
grid-row-end: 3;
}
21. Span an item over more tracks by changing
column-end/ row-end
B
.grid__item--2 {
grid-column-start: 2;
grid-column-end: 4;
grid-row-start: 2;
grid-row-end: 3;
}
32. The fr unit
• A fraction is a part of the available space in a Track
• Essentially a part of whats left after space is subtracted
• Acts similar as flex-grow in Flexbox
33. Creating three column tracks.
Using 1fr in width
We get three equally sized columns
1fr 1fr 1fr
<!-- HTML -->
<div class="grid grid--2">
<div class="grid__item grid__item--1"></div>
<div class="grid__item grid__item--2"></div>
<div class="grid__item grid__item--3"></div>
<div class="grid__item grid__item--4"></div>
<div class="grid__item grid__item--5"></div>
<div class="grid__item grid__item--6"></div>
</div>
// SCSS
.grid--2 {
grid-template-columns: 1fr 1fr 1fr;
}
34. First column = 600px
2 x 1fr columns
After 600px is subtracted, the rest is equally
devided between the two fr-columns
600px 1fr 1fr
<!-- HTML -->
<div class="grid grid--2">
<div class="grid__item grid__item--1"></div>
<div class="grid__item grid__item--2"></div>
<div class="grid__item grid__item--3"></div>
<div class="grid__item grid__item--4"></div>
<div class="grid__item grid__item--5"></div>
<div class="grid__item grid__item--6"></div>
</div>
// SCSS
.grid--2 {
grid-template-columns: 600px 1fr 1fr;
}
35. First column = 600px
1 x 1fr column
1 x 3fr column
After 600px is subtracted, the rest is
devided by 4
1fr = 25%
3fr = 75%
600px 3fr
<!-- HTML -->
<div class="grid grid--2">
<div class="grid__item grid__item--1"></div>
<div class="grid__item grid__item--2"></div>
<div class="grid__item grid__item--3"></div>
<div class="grid__item grid__item--4"></div>
<div class="grid__item grid__item--5"></div>
<div class="grid__item grid__item--6"></div>
</div>
// SCSS
.grid--2 {
grid-template-columns: 600px 1fr 3fr;
}
1fr
38. Explicit or implicit Grid Lines
• Explicit lines are specified using grid-template-rows or grid-
template-columns
• Implicit lines are created when you place elements into a row or
column track OUTSIDE of the explicit grid
• Default behaviour = auto sized
• You can specify a size with the grid-auto-columns and grid-
auto-rows properties
42. Auto-flow
• If you have items not placed in an explicit grid - > auto-flow
• Row: fill each row in turn, then add more rows
• Column: fill each column in turn, then add more columns
• Dense: try to fill holes earlier in the grid (might change order)
.grid--5 {
grid-auto-flow: row | column | row dense | column dense;
}
45. Grid is kinda like <table>
• But does not rely on content source order
• Semantic
• Can move items around with breakpoints
Grid item placement and reordering must not be used as a substitute for
correct source ordering, as that can ruin the accessibility of the document.
82. Subgrid
“The following feature are at-risk, and may be dropped during the CR period:
the subgrid value of grid-template-columns and grid-template-rows, and it’s
component parts individually”