Grid Advanced
Grid Column & Row
Use grid-column and grid-row to position items on
specific grid lines. Lines are numbered starting from 1.
Spanning Cells
Use span keyword to make items span multiple columns or
rows: grid-column: span 2.
Justify Items (Horizontal)
justify-items aligns grid items horizontally within
their cells: start, center,
end, stretch (default).
Align Items (Vertical)
align-items aligns grid items vertically within
their cells.
Justify Self & Align Self
Override container alignment for individual items with
justify-self and align-self.
Complex Layout Example
Combining all techniques to create a magazine-style layout with different sized items.
grid-column: 1 / -1 spans
from the first to the last column.
Summary
grid-column/grid-row- Position items on grid linesspan- Make items span multiple cellsjustify-items- Horizontal alignment of all itemsalign-items- Vertical alignment of all itemsjustify-self/align-self- Individual item alignment- Negative line numbers count from the end
Quick Quiz
Which property makes a grid item span 3 columns?
Enjoying these tutorials?