On
the
Grid
<img src="spacer.gif" width="50" height="30">
$ → document.querySelector
2-dimensional art direction for the web!
implicit and explicit forms
explicit - place specific elements in specific places
primary outer site layout, app interface
implicit - placement based on sequence of content
high degree of flexibility
"table view", grids, lists
display: none
display: block
display: inline
display: flex
display: grid
min-width: 100px;
max-width: 20%;
grid-template-rows:
minmax(100px, 20%)
minmax(200px, 1fr);
border-top-width: 4px;
border-left-color: cyan;
border: 4px solid cyan
<div class="page">
<header>Header</header>
<nav>Navigation</nav>
<main>Main area</main>
<footer>Footer</footer>
</div>
+--------------+
| head |
+--------------+
| nav | main |
| | |
| +--------+
| | foot |
+-----+--------+
+--------------+
| head | auto
+--------------+
| nav | main | 1fr
| | |
| +--------+
| | foot | auto
+-----+--------+
200px 1fr
head head auto
nav main 1fr
nav foot auto
200px 1fr
"head head" auto
"nav main" 1fr
"nav foot" auto
/ 200px 1fr
fallback-friendly
/* Completely Reasonable layout for older browsers */
article { ... }
@supports (display: grid) {
/* Cutting-edge layout for hip browsers */
}
Art Direction in the Second Dimension!