0Pricing
CSS Academy · Lesson

Auto-fit and Auto-fill with minmax

Create responsive column counts automatically using auto-fit and auto-fill with minmax().

The Auto-Responsive Grid

The most powerful CSS Grid pattern: a fully responsive grid that adjusts column count automatically without any media queries, using auto-fit or auto-fill combined with minmax().

auto-fill

auto-fill fills the row with as many columns as it can fit at the given minimum size. Empty columns are preserved as empty tracks at the end.

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px);
  gap: 16px;
}

All lessons in this course

  1. Named Lines and Named Grid Areas
  2. Auto-fit and Auto-fill with minmax
  3. Implicit Grid and Grid-Auto-Flow
  4. Subgrid for Aligned Nested Content
← Back to CSS Academy