CSS 3 · Grid

Make a responsive grid without media queries

Fit as many columns of at least 250px as the width allows.

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

Official CSS 3 documentation

More grid commands

All grid commands · CSS 3 cheatsheet

Was this page helpful?