Grid Layout Generator
Draw a CSS grid by dragging across cells. Set columns, rows, track sizes and gaps, and copy the CSS and HTML when it looks right. Nothing is uploaded.
No items yet. Press on a cell and drag across the cells you want an item to cover.
What this designer does
It is a visual way to write CSS grid. Choose the number of columns and rows, set the size of each track, and then drag across the cells to place items. Each item you draw gets its own grid-column and grid-row rule, and the CSS and HTML update as you work. Use the page layout example to see a header, sidebar, content and footer in one click.
Track sizes
| Value | Meaning |
|---|---|
1fr | A share of the free space. 1fr 2fr makes the second column twice as wide as the first. |
200px | A fixed size. |
auto | As big as the content needs, and it takes leftover space if nothing else does. |
minmax(100px, 1fr) | Never smaller than 100px, otherwise a share of the space. |
repeat(3, 1fr) | Three equal columns, written short. |
When you type a track list, the number of columns or rows updates to match. For responsive grids that adapt without media queries, try repeat(auto-fit, minmax(200px, 1fr)) in your own code. It cannot be drawn on a fixed grid, but it works as soon as you paste it in.
Lines, not cells
Grid items are placed by line numbers. An item that spans columns 1 to 3 is written grid-column: 1 / 4, because the number after the slash is the line where it ends. The list under the preview shows both the cells covered and the lines, so you can see how they relate. Items may overlap, which is a handy way to layer text on an image. Pair this with the Flexbox Generator for the content inside each area.
Frequently asked
How do I add an item to the grid?
Press on a cell in the preview and drag across the cells you want the item to cover, then release. It works with a mouse or a finger. Remove an item with the button in the list below the preview.
What does the fr unit mean?
fr is a fraction of the free space in the grid. With columns of 1fr 2fr 1fr, the middle column is twice as wide as each outer one, and together they fill the container.
Why does the code use numbers like 1 / 4?
CSS grid positions items by the lines between tracks. An item covering columns 1, 2 and 3 starts at line 1 and ends at line 4, so it is written grid-column: 1 / 4.
Can items overlap?
Yes. Draw an item over cells that another item already covers. Later items are drawn on top, which lets you layer elements in the same area.
How do I make the grid responsive?
Use repeat(auto-fit, minmax(200px, 1fr)) for the columns so the browser fits as many as it can. You can paste it in the column field to test it, though the visual drawing works best with fixed counts.
What is the difference between grid and flexbox?
Flexbox lays items out in one direction, as a row or a column. Grid works in rows and columns at once, so it suits whole-page layouts and anything that must line up in both directions.