How to use CSS Grid Layout Generator
- Choose whether the grid has a fixed number of columns or fits as many as will go at a minimum width.
- Set the columns, rows and gap. Add a stacking breakpoint if the grid should change on a narrow screen.
- Check the preview, then copy the CSS rule and the matching HTML. The two blocks describe the same grid you see.
Example: CSS Grid Layout Generator
Build a three column grid that becomes one column on a phone.
Supported inputs and limits
Where your input is processed
This tool processes your input in this browser. Your text and files are not uploaded to UseFreeTools. Check this tool's limits for anything it may save on your device.
Why next to nothing sits on the columns
A grid rule describes tracks, not content. The generator writes columns, rows and the gap, and the HTML shows which element lands in each track. In a real page the cell contents decide the height of each row, so a taller card in one column moves its whole row down. Check the rule with real content before you settle on a fixed row count.
Questions about CSS Grid Layout Generator
When should I use the fit-as-many model?
Use it when the number of columns should follow the available width, such as a card list. Each column is at least the minimum width you set, and the browser fits as many as will go. Use the fixed model when the layout must have a set number of columns.
Why do the preview columns not match my own layout?
The preview box is as wide as the workspace panel and it swaps at the viewport breakpoint you set. A real container can be narrower, carry padding, or hold wider content, so fewer columns may fit there. Paste the rule into your stylesheet and check the element at its real size.
What does the breakpoint actually do?
Below the width you set, the grid switches to the mobile column count with one max-width media query. Set the breakpoint to 0 to leave that rule out and keep one column count at every width.
Does the numbered cell HTML ship with styling?
No. The HTML block is a plain wrapper with one div per cell so you can see the count at a glance. Replace the numbered divs with your own content, and add the cell styling in your stylesheet.