CSS Grid Generator
Build CSS Grid layouts visually. Set columns, rows and track sizes with fr, px, %, auto or minmax, adjust gaps, auto-flow and alignment, place items explicitly without overlaps, try a random layout and copy the CSS.
Build CSS Grid layouts visually. Set columns, rows and track sizes with fr, px, %, auto or minmax, adjust gaps, auto-flow and alignment, place items explicitly without overlaps, try a random layout and copy the CSS.
CSS Grid Generator helps you design a grid layout and see it immediately. Choose up to 12 columns and 12 rows and give every track the same size or a size of its own, using safe controlled choices: fr, px, %, auto or minmax(px, fr). Set the column and row gap, the container width and height, grid-auto-flow and all four alignment properties — justify-items, align-items, justify-content and align-content — and change how many numbered sample items fill the grid.
Select an item to give it an explicit grid-column and grid-row with a span, or its own justify-self and align-self. The tool checks every placement: an item may not extend past the explicit grid or overlap another explicitly placed item, and placements that no longer fit after you shrink the grid are switched back to automatic placement with a note. A Random Layout button produces a valid layout from controlled values. The generated CSS uses repeat() where tracks match and nth-child rules only for items you changed.
px is a fixed size and % is a share of the container. fr shares the remaining free space between fr tracks, and auto sizes a track to fit its content. minmax(min, max) keeps a track at least the minimum size and lets it grow up to the maximum.
An explicitly placed item must stay inside the explicit grid you defined and may not overlap another explicitly placed item. The tool shows which item would overlap so you can move or shrink one of them.
The browser creates extra implicit rows (or columns, with column auto-flow) sized auto to hold them. The tool tells you when this happens; implicit tracks are not part of the generated template.
Dense packing lets the browser fill earlier gaps with later items that fit, which can change the visual order of items. It is useful for galleries but can confuse readers if order matters.
A .grid-container rule with the template, gap, auto-flow, alignment and size, plus .grid-item:nth-child(n) rules for items you placed or aligned individually.
The generated CSS is standard CSS Grid supported by all current major browsers. Very old browsers are not targeted.