Grid Cheatsheet
Grid Cheatsheet
display
align-content
gaps
container alignment
auto placement
specifying size of row and column gutters automatic placement for items that aren't placed
vertical alignment for whole grid
1
.parent { 1 2 3 .parent { start· end· center· stretch· space-around
2
row-gap: 50px; 4 5 6
grid-auto-flow: row; space-between· space-evenly
3 } }
4
7 8
justify-content
horizontal alignment for whole grid
1
.parent { 1 4 7 .parent { start· end· center· stretch· space-around
column-gap: 50px; grid-auto-flow: column;
2
2 5 8 space-between· space-evenly
3
} }
place-content
4 3 6
justify-items
grid-row-start grid-row-end grid-row horizontal alignment for items in their cells
placing items
auto· line name· line number auto· line name· line number shortcut for grid-row-start|end start· end· center· stretch
place-items
grid-column-start grid-column-end grid-column shortcut for align-items and justify-items
auto· line name· line number auto· line name· line number shortcut for grid-column-*
shortcut for… everything keyword for row or column spanning horizontal alignment for specific item in its cell
start· end· center· stretch
.two {
grid-row-start: 1;
.two {
.two {
.four {
align-self
grid-row-end: 3;
grid-row: 1 / 3;
grid-row: 1 / span 2;
grid-area: 2 / 2 / 3 / 3;
vertical alignment for specific item in its cell
} } } } start· end· center· stretch
1 1 1 1 2
place-self
3
2
3
2
3
2
3 4
shortcut for align-self and justify-self
patterns
.parent {
.parent {
align-content: center; grid-auto-rows:
.parent {
.parent {
justify-content: center;
auto 1fr auto;
grid-template-columns: repeat(2, 100px 1fr);
grid-template-columns: repeat(4, 22%);
} } } justify-content: space-between;
}
header
main
footer
english francophone
resources