Course contentsShow
← Web Development
Lesson 334 of 2,9826. CSS GridFree lesson

Common minmax() Patterns

Explore practical minmax() combinations like minmax(0, 1fr) and minmax(min-content, max-content).

Common minmax() Patterns

What you'll learn: You'll discover the most useful real-world ways developers combine minmax() to create flexible, resilient grid layouts.

Now that you understand how minmax() constrains track sizes, let's look at patterns you'll use constantly in everyday projects.

The Most Common Combinations

minmax(0, 1fr) — The Flexible Track

This pattern creates a track that can shrink to zero width but will grow to fill available space. It's perfect when you want columns to be truly flexible and willing to collapse if necessary:

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

Think of this as saying: "I don't care how small you get, but share the available space equally when possible."

minmax(min-content, max-content) — The Content-Driven Track

This lets a track shrink to its narrowest content but expand to its widest content without wrapping. It's ideal for columns that should adapt to their content's natural size range:

.grid {
  display: grid;
  grid-template-columns: minmax(min-content, max-content) 1fr;
  gap: 1rem;
}

The first column will be as small as its longest word but as wide as its longest line of text.

minmax(200px, 1fr) — The Responsive Track

This is your go-to for responsive columns that never get too cramped: they'll never shrink below 200px but will grow to fill space. Perfect for card layouts and content columns.

Why These Matter

These patterns solve real problems: preventing text overflow, creating equal-height columns that respect content, and building responsive layouts without media queries.

Key Takeaway: Master minmax(0, 1fr) for fully flexible tracks, minmax(min-content, max-content) for content-aware sizing, and minmax(fixed, 1fr) for responsive columns with minimum sizes.