Grid layouts
Exercise35 min
Grid layouts
CSS Grid divides a surface into rows and columns — a real 2D layout:
.page {
display: grid;
grid-template-columns: 240px 1fr; /* sidebar, then flexible content */
gap: 24px;
}Where flexbox distributes along one axis, grid places things on a map. Use grid for page scaffolding (sidebar + main, card galleries) and flexbox for what goes inside each cell. 1fr means "one share of the leftover space" — the single most useful grid unit you will learn.
Exercise
Make a two-column layout: sidebar 240px, content 1fr. Add a header row that spans both columns with grid-column: 1 / -1.
Practice in the diagram lab
This lesson's practice belongs in the diagram editor — design the schema you just read about, grade it against the solution, and save it to your account.
Open the diagram lab