CSS Grid Generator

Set the columns, rows and gap of a CSS grid, see the cells laid out live and copy the CSS. Handy presets cover common layouts.

Processed on your device. Files are not uploaded

How to try CSS grid layouts

  1. Pick a preset or write your own

    Use columns like repeat(3, 1fr) or 240px 1fr.

  2. Check the preview

    Watch the live preview change as you adjust.

  3. Copy the CSS

    Paste the rules onto your container.

Worked example

This is what CSS Grid Generator gives for its own sample values. Open the tool above and change anything to try your own.

Start from
The values below
grid-template-columns
repeat(3, 1fr)
grid-template-rows (optional)
gap (px)
12
Boxes to preview
6

CSS

display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;

About CSS Grid Generator

Set the columns, rows and gap of a CSS grid and see the cells laid out. Presets cover three equal columns, a sidebar, responsive cards and a page layout.

FAQs

What does 1fr mean?

One share of the free space. Two columns of 1fr are equal, and 2fr takes twice as much.

How do I make cards that wrap?

Use repeat(auto-fill, minmax(160px, 1fr)) so as many columns fit as there is room for.

Should I use flexbox instead?

Use CSS Flexbox Generator for a single row or column.

Related tools