A responsive CSS Grid adjusts its column count automatically as the container narrows or widens, without a single media query in the stylesheet. The pattern relies on two features built into the grid-template-columns property: the auto-fill keyword inside repeat() and the minmax() function that defines a size range for each column track. FixTools generates the correct repeat() value for your chosen minimum column width and previews exactly how the grid collapses as the container width decreases through tablet and mobile breakpoints. The resulting CSS is one declaration that handles every viewport size from a 4K monitor down to a 320px phone, with the browser doing all the column-count arithmetic at runtime.
Generates repeat(auto-fill, minmax()) values with correct syntax
Live preview shows column count at different container widths
Supports auto-fill and auto-fit comparison
CSS Tool
All processing happens in your browser — your files are never uploaded to any server.
🚀Open Grid Flexbox Builder100% Free · No account · Works on any device
A responsive CSS Grid without media queries works because of how the browser resolves the repeat() function in combination with the auto-fill keyword and minmax() function. The value repeat(auto-fill, minmax(250px, 1fr)) instructs the browser to create as many columns as will fit into the container, given that each column must be at least 250px wide and is allowed to grow up to one equal share of the remaining space. If the container is 1100px wide with a 20px gap, the browser fits four columns each roughly 255px wide. If the container narrows to 700px, it fits two columns each roughly 330px wide. If it narrows further to 320px, it fits a single column that fills the container. No media query specifies these breakpoints; the browser calculates the column count continuously as the container resizes, which makes the layout inherently fluid rather than stepping through fixed breakpoints.
The auto-fill and auto-fit keywords are two closely related options that control what happens when items do not fill all available columns in the last row of the grid. The auto-fill keyword creates as many column tracks as the container allows, even if some tracks are empty at the end of the last row because there are fewer items than columns. The result is that partial rows of cards do not stretch to fill the container: a three-item row in a four-column grid shows three normal-width cards and one empty track. The auto-fit keyword collapses those empty tracks and stretches the filled columns to share the full container width between them. For most card grids and product listings, auto-fill is the correct choice because it maintains consistent card widths regardless of how many items appear in the final row.
Choosing the right minmax minimum value is the key design decision in a responsive Grid, and it determines the column counts at every viewport size. The value minmax(250px, 1fr) creates columns that are at least 250px wide and expand equally to fill remaining space. If your cards have readable content at 220px and look polished up to 400px, a minimum of 240px gives natural breakpoints at common container widths. Too small a minimum such as 100px results in many narrow columns at large viewport sizes that overwhelm the page with thin tracks; too large a minimum such as 400px results in a single column appearing too early on medium screens where the design called for two or three. The generator previews column count at several container widths so you can confirm the minimum value produces the column counts your design requires at the breakpoints you care about.
Beyond the column count behaviour, responsive grids also need to consider gap, alignment, and overflow handling to behave predictably in real-world content scenarios. A consistent gap of 16px to 24px works for most card grids, with smaller gaps producing denser layouts and larger gaps producing more breathing room. The align-items: stretch default makes all cards in a row share equal heights, which is usually desirable; switching to align-items: start lets cards size to their content individually when uniform heights are not needed. For text-heavy content that may contain long unbroken words or URLs, switching the minmax minimum from a pixel value to 0 (as in minmax(0, 1fr)) prevents content from forcing tracks wider than expected, which is one of the most common debugging fixes for production responsive grids.
Set your minimum column width in the generator, choose auto-fill or auto-fit, add a gap value, and copy the output. The grid-template-columns value uses repeat() with minmax() and adapts column count automatically.
Step-by-step guide to responsive css grid:
Set your minimum column width
Enter the minimum width each column should be before the browser drops to fewer columns to maintain readable card sizes. A value of 250px to 300px works for most card grids with text content and small images; tighter 200px values suit compact data tiles; larger 320px values fit content-heavy preview cards with featured images. The preview updates immediately so you can see how many columns appear at the current container width before adjusting any other property.
Choose auto-fill or auto-fit
Select auto-fill if card widths should stay consistent across all rows including partially filled ones, which is the right choice for most product grids and galleries. Select auto-fit if the last row of items should stretch to fill the container width when there are fewer items than the maximum column count. The two keywords look identical when the grid is full and only differ in their behaviour on partial last rows, so test both with realistic item counts to confirm the desired behaviour.
Set the gap value
Add a row and column gap value, typically between 16px and 24px for card grids. The gap is factored into the column count calculation by the browser, so set it before finalising your minimum column width to avoid recalculating column counts after the fact. You can also set row-gap and column-gap separately if your design calls for different vertical and horizontal spacing between cards, such as tighter horizontal gaps with looser vertical ones.
Copy the grid-template-columns value
Click Copy CSS to copy the complete container ruleset with the repeat(auto-fill, minmax()) value, the gap, and any alignment properties you configured. Paste it into your stylesheet on the card container selector. The output works in every modern browser without vendor prefixes, and it produces consistent responsive behaviour from mobile through to ultra-wide desktop monitors with no additional media queries required.
Common situations where this approach makes a real difference:
E-commerce product grid
An online shop uses repeat(auto-fill, minmax(240px, 1fr)) with gap: 20px for its main product listing page. At 1280px container width the grid shows five columns of roughly 240px each; at 960px it shows four columns; at 720px it shows three; at 480px it shows two; and at narrower widths it collapses to a single column. No breakpoints are defined in the CSS at all. Product cards maintain consistent widths at every viewport size between these natural break points, and the last row never shows stretched cards because auto-fill keeps the empty tracks rather than collapsing them.
Photography portfolio gallery
A photographer wants a tight gallery that adjusts column count automatically as the viewport changes. Using repeat(auto-fill, minmax(280px, 1fr)) with gap: 8px creates a dense grid that shows four columns on a 1200px wide container and drops to two columns on a 600px tablet view in landscape. The tight 8px gap visually unifies the gallery into a single visual block rather than a collection of separate cards. The gallery requires zero media queries to maintain its responsive behaviour and works correctly on every screen width from mobile portrait through to ultra-wide desktop monitors.
Blog post card listing
A blog index page uses repeat(auto-fill, minmax(320px, 1fr)) for article preview cards that each contain a featured image, a title, an excerpt of around forty words, and a publication date. The larger 320px minimum width ensures the excerpt text is readable at every column width without truncating to one or two visible lines. Three columns appear on a typical desktop monitor, two columns appear on tablets in portrait orientation, and one column appears on mobile phones narrower than around 700px. The single declaration handles every device the blog's audience uses.
Team member directory
A company team page with profile cards uses repeat(auto-fit, minmax(200px, 1fr)) instead of auto-fill, because the team has only twelve members and the last row of cards often has only one or two members rather than a full row. The auto-fit choice ensures the final row of cards stretches to fill the container width, matching the visual width of complete rows above rather than leaving an awkward empty space on the right. The smaller 200px minimum keeps profile cards compact since they only need to display a photo, name, title, and a couple of social icons.
Use this when building a card grid, image gallery, or product listing where column count should adapt to container width automatically without writing breakpoint-specific media queries.
Get better results with these expert suggestions:
Set gap before choosing your minimum column width
The browser subtracts the total gap space from the container width before calculating how many columns fit, which means changing the gap after you finalise your column minimum shifts the column count at every viewport size. A 16px gap across five columns removes 64px from the available width. Set the gap value first, then adjust your minmax minimum so the column count at the widths you care about matches your design intent. This habit prevents the late surprise where adding a larger gap suddenly drops your three-column layout to two.
Use auto-fill for consistent card widths, auto-fit for stretching final rows
The auto-fill keyword keeps card widths consistent across all rows including the last partial row, while auto-fit stretches the cards on the final row to fill the container width when there are fewer items than column tracks. If your last row commonly has one or two items and you do not want them stretched to fifty or one hundred percent width, choose auto-fill. If your last row should always look like the rows above, even when it has only one card, choose auto-fit. Match the keyword to your design intent rather than guessing.
Test at the exact width where columns drop from three to two
Find the container width where your minmax value causes the grid to drop from three to two columns and verify the cards look correct at that exact transition. Cards often jump from around 300px to 500px wide at this transition, which can expose layout issues in card content that is not flexible enough to handle the wider variation. Internal card images may need to switch from cover to contain, text may need to wrap differently, and buttons may need to grow with their container.
Add align-items: start to prevent short cards from stretching
By default, Grid stretches items to fill the full row height through align-items: stretch, which is usually what you want for cards with prices or buttons that should align across the row. In a card grid where you specifically want cards to size to their own natural content height, add align-items: start to the grid container. The default stretch behaviour is correct when all cards in a row should share equal heights for visual consistency, but it produces awkward empty space in cards with much less content than their row siblings.
More use-case guides for the same tool:
Open the full Grid Flexbox Builder — free, no account needed, works on any device.
Open Grid Flexbox Builder →Free · No account needed · Works on any device