Sikau

CSS · Day 10 · about 30 min

Grids that fit any screen

auto-fit, minmax and named areas.

No media queries needed

One line of Grid can make a card layout that shows four columns on a laptop, two on a tablet and one on a phone — automatically. And named areas let you sketch a whole page layout in ASCII art.

auto-fit + minmax, and grid areas

  • minmax(140px, 1fr) — each column at least 140px, at most an equal share.
  • repeat(auto-fit, …) — fit as many columns as the width allows.
  • grid-template-areas — name regions with strings; grid-area places an item.

The rest of this lesson

  • How auto-fit decidesexplain
  • Page layouts with named areasexplain
  • How many columns?predict
  • Fit the columnspredict
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 19 lessons of CSS