Cubestack

CSS Grid Generator

Free CSS grid generator — set columns, rows and gaps, or make a responsive auto-fit grid, preview it live and copy the CSS, HTML and Tailwind classes.

1
2
3
4
5
6

CSS

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 120px);
  gap: 16px;
}

HTML

<div class="grid">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

Tailwind

grid grid-cols-3 gap-[16px]
112
18
px
064

What is the CSS Grid Generator?

CSS Grid lays out content in rows and columns. This generator writes the grid-template CSS for fixed or responsive layouts and shows the result as you change it.

How to use it

  1. 1

    Choose columns and rows

    Or turn on responsive.

  2. 2

    Set the gap and sizes

    Watch the preview.

  3. 3

    Copy the code

    CSS, HTML or Tailwind.

Features

  • Fixed or responsive

    Set columns, or let them auto-fit a minimum width.

  • Any track size

    fr, px, minmax() and more.

  • Three outputs

    CSS, HTML and Tailwind classes.

Popular uses

  • Card grids

    Product and blog listings.

  • Dashboards

    Panel layouts.

  • Galleries

    Responsive image grids.

Frequently asked questions

What does auto-fit do?

Fits as many columns as there's room for, each at least the minimum width.

What is 1fr?

One share of the free space.

Related tools