Lesson 1 of 8

CSS Grid

Goal

Layout in two directions

01

Explanation

Flexbox lays items out in one direction, while Grid lays them out in two at once, in columns and rows. That's why Grid is shorter and clearer whenever your layout really is a grid.

The line grid-template-columns: repeat(3, 1fr) creates three equal columns. The fr unit means “a share of the remaining space”, not a fixed size.

The most powerful line in Grid is this one: repeat(auto-fit, minmax(160px, 1fr)). It builds a grid that picks its own number of columns based on the available width, without a single media query.

02

Your task

Make .gallery a grid of three equal columns with a gap of at least 12px between them.

Checks

4 checks
  1. .gallery is a grid container
  2. The grid has three columns
  3. The columns are the same width
  4. The tiles are at least 12px apart
03

Hints

0/3
Track lessons0 of 8 done

Learn page layout, form validation, motion and accessibility: the things that make an interface comfortable to use in real life, not just nice to look at.

Advanced level, 8 lessons, 2 hours in total.

index.html
Preview
index.html100%
–/4

Press “Run and check” to grade your code.

4 checks listed under “Your task”.

Track lessons0 of 8 done

Learn page layout, form validation, motion and accessibility: the things that make an interface comfortable to use in real life, not just nice to look at.

Advanced level, 8 lessons, 2 hours in total.