How to use CSS Grid Layout Generator
- Choose Fixed number of columns or Fit as many as will go. Enter the fixed column count or the auto-fit minimum width.
- Set Rows and Gap in pixels. Columns × Rows determines how many numbered cells the sample and HTML contain, including in auto-fit mode.
- Set a viewport breakpoint and Mobile columns, or enter 0 for no media query. Compare the preview at wide and narrow browser sizes.
- Select Generate grid and copy the CSS and matching HTML. Replace the sample cells with real content and test in your actual container.
Example: CSS Grid Layout Generator
Build six sample cells in three columns, switching to one column at a viewport width of 768 pixels or less.
Options
- Fixed columns
- Use 1 to 12 equal columns. Rows accepts 1 to 12 and writes the explicit row count for this mode; row heights follow the content.
- Auto-fit columns
- Choose a minimum width from 80 to 600 pixels. The CSS fits as many columns as the container allows and clamps the minimum to 100% of a narrower container. Columns × Rows still sets the sample cell count; the actual number of rows depends on available width.
- Gap
- Use a whole number from 0 to 64 pixels between tracks. The gap also uses space that columns must share.
- Viewport breakpoint
- At a viewport width at or below the selected 1 to 2000 pixels, a max-width media query uses Mobile columns, from 1 to 12. Set 0 to omit that rule. Auto-fit then continues responding to container width; fixed mode keeps its column count.
Supported inputs and limits
- Whole-number inputs, up to 12 Columns and 12 Rows, producing at most 144 numbered sample cells.
- Gap is 0 to 64 pixels, viewport breakpoint is 0 to 2000, and the auto-fit minimum is 80 to 600 pixels.
- One optional max-width query sets the mobile column count.
- The tool writes layout CSS and plain cell markup; it does not add cell styling, named areas, container queries or per-cell placement.
- Real content can create additional rows or change their height.
More details
The preview uses its own panel width and the browser’s viewport breakpoint, which may differ from your final container.
Where your input is processed
This tool does not upload your inputs. See the limits for anything saved on your device.
A sample row count does not limit real content
The copied HTML contains Columns × Rows numbered cells. Fixed mode defines that many explicit rows, while auto-fit creates rows as needed. Adding more items can create implicit rows. Replace the sample with actual text and images before choosing final dimensions; the generator does not know their size.
Questions about CSS Grid Layout Generator
When should I use the fit-as-many model?
Use it for a list where the column count should follow the available container width. The selected minimum is clamped to the container if it is narrower. Above the optional mobile breakpoint, the browser fits as many tracks as space permits. Fixed mode gives a specified column count.
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?
At the selected viewport width or smaller, the max-width query uses Mobile columns. Set the breakpoint to 0 to omit that override. Fixed mode then keeps its count, while auto-fit still changes with available container 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.