Explore Bato Web Agency Webflow Certified Partner Profile Explore Bato Web Agency Webflow Certified Partner Profile

How do you use minmax() for a responsive grid?

Illustration without a description Illustration without a description

Use minmax() to give each grid track a usable minimum and a flexible maximum. Combined with repeat() and auto-fit, it creates columns according to available space without a media query for every count. The minimum should come from the card’s content.

 

A common pattern is:

 

.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
gap: 1.5rem;
}

 

The track never becomes narrower than 18rem when that width is available, and it grows up to one fractional share of the row. The inner min(100%, 18rem) lets the grid fit inside a container narrower than 18rem instead of forcing horizontal overflow.

 

Avoid minmax(auto, 1fr) when a long word or intrinsic image can establish an unexpectedly large minimum. Use minmax(0, 1fr) for tracks that must be allowed to shrink, then handle wrapping or local overflow inside their items.

 

Test the shortest and longest cards, different item counts and nested containers. A responsive grid still needs image constraints, readable line lengths and logical DOM order. Use a container query when a card’s internal layout should change after its grid track becomes wide enough. Test the finished component with keyboard focus, touch input and a resized desktop window. Responsive geometry works only when controls stay reachable and the visual sequence matches the document order. Verify the behavior across the full width range, including spaces between design breakpoints. Long labels, translated copy and enlarged text can expose constraints that short sample content never reaches. Verify the behavior across the full width range, including spaces between design breakpoints. Long labels, translated copy and enlarged text can expose constraints that short sample content never reaches.