Free Online CSS Grid Generator with Track Units
Build a grid track by track, giving each column and row its own unit: fr, px, auto, min-content or max-content. There is an auto-fit and minmax mode for responsive columns, controls for gap, alignment and auto-flow, and you can place one item across a span of columns and rows.
Cells are numbered in source order. The placed item is highlighted. Columns: 1fr 1fr
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
How to Build a CSS Grid
A few steps, and nothing is uploaded.
What to Know About CSS Grid
Including why fr and per cent are not interchangeable.
repeat(3, 1fr) with a 16px gap fits exactly. Three tracks of 33.33% use the full container width and then the two gaps are added on top, which is 32px more than there is room for, so the grid overflows. If you have ever added a gap and watched a layout break, this is why. Use fr, and keep percentages for cases where you really do want a share of the container rather than a share of the space left.
repeat(auto-fit, minmax(220px, 1fr)) the empty tracks are collapsed, so three cards stretch to fill the row. With auto-fill the empty tracks are kept, so three cards sit at 220px each and leave a gap on the right. This page writes auto-fit, which is what a card grid almost always wants, but the difference is worth knowing before you copy a rule from elsewhere.
grid-auto-rows, which defaults to auto. That is usually fine, but it is the reason a grid can look uneven when the content is longer than expected. This page keeps the cell count equal to the track count so the preview matches the definition exactly.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
About the CSS Grid Generator
CSS Grid is defined by its track list, and almost everything else follows from getting that list right. The syntax allows a different unit on every track, which is what makes it genuinely two dimensional, but it also means a generator that offers one unit for the whole grid is not much use. This page gives each column and each row its own size and unit so that a 240px sidebar next to a 1fr body is as easy as three equal columns.
The auto-fit mode exists because that one pattern covers most real work. A card grid that should hold as many columns as will fit, each at least 220px wide and sharing the leftover space, is written as a single repeat with minmax, and typing it from memory is error prone. Switching modes here writes it correctly and shows you the result in a real grid container.
The fiddly part was the preview. Because the number of cells is tied to the number of tracks, changing the row count has to rebuild the cells without losing the track sizes you have already set, and placing an item has to apply to the right cell after a rebuild. The cells are numbered so that the placed item, and the way grid-auto-flow reorders things around it, can actually be seen rather than imagined.
Frequently Asked Questions
Track units, auto-fit, spans and implicit rows.