Skip to content
Guest
Learn CSS · Course Syllabus Show lessons
Layout Systems · 9 min read · Beginner

CSS Grid Basics

Build responsive two-dimensional layouts with CSS Grid, fr units, and auto-fit without writing media queries.

What you'll learn

  • Create multi-column grids using grid-template-columns and fr units
  • Build an auto-responsive card grid using repeat(auto-fit, minmax(...))

While Flexbox excels at a single row or column, CSS Grid (display: grid) lets you control rows and columns simultaneously.

The Magic Responsive One-Liner

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

Try It Yourself

Try changing 140px to 100px or 220px and see how the cards reflow!

Responsive CSS Grid
Live Result

Check Your Understanding

Score: 0 / 1

1. What does the 1fr unit represent in CSS Grid?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind