CSS Grid Generator
Design CSS grid layouts visually. Choose columns, rows and gaps, set alignment, make items span cells, and copy clean CSS and HTML.
Selected item
CSS
HTML
How to use CSS Grid Generator on KickSolve
Three quick steps, no account needed.
Why choose KickSolve
Built for speed, privacy and clean results.
What you can do with CSS Grid Generator
Everything this tool offers.
About CSS Grid Generator on KickSolve
What it does and how to get the best results.
How the CSS grid generator works
The settings are applied to a live preview container, and the same values are written into the CSS you copy. The Columns and Rows sliders create repeat() tracks with 1fr units, and you can overwrite them with any valid track list. Item spans are added with nth-child selectors, so only the items you changed appear in the code.
Grid terms you should know
A grid container holds the layout. Tracks are its rows and columns, cells are the single spaces between tracks, and gaps are the gutters between them. Items can span several tracks. The fr unit divides the free space, which makes flexible layouts easy to describe.
Useful grid patterns
- Equal columns: repeat(3, 1fr).
- Sidebar layout: 250px 1fr.
- Responsive gallery: repeat(auto-fit, minmax(200px, 1fr)).
- Holy grail layout: header and footer items spanning all columns.
- Dashboard tiles: items spanning two columns or two rows.
Alignment in grid
Justify-items aligns items horizontally within their cell and align-items aligns them vertically. The default stretch fills the cell. Use start, center or end to let items keep their natural size inside the cell.
Grid vs flexbox
Grid is two-dimensional, so it controls rows and columns at once and is ideal for page structure. Flexbox is one-dimensional and is ideal for aligning content inside a component. Most real layouts use both.
Good to know
- The preview container has a fixed height of 320 pixels so row tracks are visible.
- Invalid track values are ignored by the browser, so the preview keeps the last valid layout.
- The number of items follows columns times rows, up to 48, and you can change it.
Grid properties at a glance
The properties used by this generator.
| Property | What it does | Example |
|---|---|---|
| grid-template-columns | Defines the column tracks | repeat(3, 1fr) |
| grid-template-rows | Defines the row tracks | auto 1fr auto |
| gap | Sets the space between rows and columns | 16px 24px |
| justify-items | Aligns items horizontally in their cells | center |
| align-items | Aligns items vertically in their cells | start |
| grid-auto-flow | Controls automatic placement of items | row dense |
| grid-column | Makes an item span columns | span 2 |
| grid-row | Makes an item span rows | span 2 |
Frequently asked questions
Quick answers.
What is CSS grid?
CSS grid is a two-dimensional layout system. You define rows and columns on a container with display: grid and place items into the cells, which makes page and component layouts much simpler than floats or positioning.
What does the fr unit mean?
The fr unit is a share of the free space in the grid container. With grid-template-columns: 1fr 2fr, the second column gets twice as much of the leftover width as the first.
What does repeat(3, 1fr) do?
It is shorthand for three equal columns, the same as writing 1fr 1fr 1fr. Changing the Columns slider rewrites this value for you, and you can also type your own track sizes.
How do I make an item span multiple columns or rows?
Select the item in the preview and set Column span or Row span. The generator adds a grid-column or grid-row rule with span to that item.
What is the difference between justify-items and align-items?
Justify-items aligns items horizontally inside their cells and align-items aligns them vertically. The default value stretch makes items fill the whole cell.
What does grid-auto-flow do?
It controls how items that are not placed explicitly fill the grid. Row fills across first, column fills down first, and the dense option backfills gaps left by larger items.
What is the difference between gap, column-gap and row-gap?
Gap is shorthand that sets the row gap and the column gap together. If both are equal, the generator writes a single value, otherwise it writes the row gap first and then the column gap.
How do I make a responsive grid?
Use repeat(auto-fit, minmax(200px, 1fr)) for the columns. You can type this into the grid-template-columns field to preview a layout that adds and removes columns as the width changes.
Should I use grid or flexbox?
Use grid when you need to control rows and columns together, for example a page layout or a gallery. Use flexbox for one-dimensional layouts such as toolbars and navigation.
Is anything uploaded or stored?
No. The generator runs in your browser and nothing is sent to a server.
More free tools from KickSolve
Related everyday tools.