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

How do you build a responsive card grid with CSS Grid?

Illustration without a description Illustration without a description

Build a responsive card grid with CSS Grid by giving each card a usable minimum width and allowing the browser to create as many columns as fit. repeat(), auto-fit and minmax() can remove the need for several viewport breakpoints.

 

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

 

The inner min(100%, 18rem) prevents the 18rem minimum from overflowing a container narrower than 18rem. Each track grows up to one fractional unit, distributing extra space across the row. auto-fit collapses empty tracks, which usually lets existing cards stretch.

 

Choose the minimum from card content, not a device class. Test the longest heading, image ratio, metadata and actions. Keep cards semantically independent and avoid forcing equal fixed heights that clip enlarged text. Grid’s default stretch can align backgrounds while inner flex layout positions actions without absolute coordinates.

 

Add container queries when the card’s internal layout should change as its track grows. Test one card, a partially filled final row, many cards and a narrow embedded grid. Reserve image dimensions to reduce layout shift, and keep DOM order equal to reading order. Visual grid placement should not rearrange important cards. Recheck the component after font, spacing or browser-support changes. Responsive failures often return when a shared token changes, so the test should cover the limiting content state instead of one ideal screenshot. Verify the final behavior across the full width range, including the spaces between preset devices and design breakpoints. Long labels, translated copy and enlarged text often reveal constraints that short demo content does not exercise.