Named grid areas in CSS
Drawing the layout as a picture, then dropping elements into named cells.
.page {
display: grid;
grid-template-columns: 16rem 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas:
"header header"
"side main"
"footer footer";
min-height: 100vh;
}
.page > header { grid-area: header; }
.page > aside { grid-area: side; }
.page > main { grid-area: main; }
.page > footer { grid-area: footer; }
How it works
grid-template-areasis an ASCII map of the layout.- A dot marks a cell left deliberately empty.
- Each child claims its cell with
grid-area.
Keywords and builtins used here
displaygridpageremvh
The run, in numbers
- Lines
- 15
- Characters to type
- 329
- Tokens
- 73
- Three-star pace
- 80 tpm
At the three-star pace of 80 tokens a minute, this run takes about 55 seconds.
Step 3 of 7 in Grid, step 9 of 24 in Flexbox & grid.