Tool guide
About this tool.
- CSS Grid places items in rows and columns. This generator writes a .layout rule with a fixed number of equal columns, repeat(Columns, minmax(Minimum track, 1fr)), so every column is at least that wide and shares the remaining space equally.
- Rows use repeat(Rows, minmax(80px, auto)): at least 80 px tall and taller when content needs it. Items beyond the explicit cells go into extra tracks according to Auto flow.
- Item alignment (justify-items, align-items) positions each item inside its cell. Content distribution (justify-content, align-content) positions the whole set of tracks, which only shows when the tracks leave spare space.
- Lay out card grids, galleries and dashboards with a fixed column count and separate row and column gaps.
- See how row or column auto flow and dense packing place numbered items before writing the CSS by hand.
- Find out when minimum track widths overflow a narrow container instead of shrinking.
- Copy a starting container rule, then add spans, explicit placement or breakpoints in your own stylesheet.
Set Columns, Rows and Minimum track with the sliders or number boxes, or pick a sample from Apply sample.
Adjust Column gap and Row gap separately and watch the numbered items in the live preview.
Choose Auto flow, Item alignment and Item vertical alignment for items, and Content distribution and Content vertical distribution for the tracks as a whole.
Copy the CSS or download grid.css and the css-grid-report.json audit; scroll inside the preview when the columns are wider than the stage.
- Columns 3, Minimum track 180, gaps 16 → grid-template-columns: repeat(3, minmax(180px, 1fr)); column-gap: 16px; row-gap: 16px;
- Rows 2 → grid-template-rows: repeat(2, minmax(80px, auto));
- Columns 2, Column gap 8, Row gap 24, Minimum track 80 → repeat(2, minmax(80px, 1fr)) with column-gap: 8px; row-gap: 24px;
- Auto flow Column, Rows 3 → grid-auto-flow: column; items fill each column top to bottom before the next one.
- Item alignment Center, Item vertical alignment Center → justify-items: center; align-items: center;
- Columns 6, Minimum track 600 → repeat(6, minmax(600px, 1fr)), at least 3,680 px wide with the default 16 px gaps, so the preview scrolls.
- Columns accept 1–12, Rows 1–8, Column gap and Row gap 0–96 px and Minimum track 40–600 px, as whole numbers. Empty, fractional and out-of-range values show an error instead of being rounded or clamped.
- The output always uses a fixed repeat() count, not auto-fit or auto-fill, and adds no media queries, so the minimum track width is kept on narrow screens.
- Rows always get an 80 px minimum height; content can make them taller.
- Content distribution can look unchanged because 1fr columns already fill the width; it shows with fewer or fixed-size tracks.
- Column and dense flow can change the visual order of items relative to the HTML; keyboard and screen reader order still follow the markup.
- Only the .layout container rule is exported. Preview labels, colors and stage size are not part of the CSS.