blackdroid.dev

CSS Grid Generator & Playground

Design CSS Grid layouts visually — columns, rows, track sizing, gap and alignment with a live preview. Copy the generated CSS for free.

1
2
3
4
5
6
7
8
9
CSS
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, auto);
  gap: 8px;
}

About CSS Grid Generator & Playground

Configure a CSS Grid — column and row counts, track sizing (fr, minmax, auto, fixed), gap and item alignment — and watch the layout update live.

Copy the finished grid-template CSS with one click. Everything runs in your browser.

CSS Grid thinks in two dimensions where flexbox thinks in one, which is why page-layout work belongs to grid: you declare columns and rows as tracks — 1fr 2fr 1fr means proportional columns — and items place themselves or span explicitly. The generator exposes the track syntax visually so the relationship between the GUI and the code becomes obvious.

The concepts that matter most: fr units distribute free space proportionally (not fixed fractions of the container), gap replaces margin hacks entirely, and auto-fill with minmax creates responsive grids without media queries — the single most valuable grid pattern. Master those three and most layout problems stop requiring frameworks.

How to use CSS Grid Generator & Playground

  1. Set column and row counts plus the track sizing mode.
  2. Tune the gap and item alignment while watching the preview.
  3. Copy the generated .grid CSS block.

Frequently asked questions

What does repeat(3, 1fr) mean?

Three columns each taking an equal fraction of the free space — 1fr divides remaining width equally after fixed tracks are placed.

When should I use minmax?

minmax(0, 1fr) prevents content from overflowing its track — plain 1fr lets long content force the column wider.

Grid or Flexbox?

Grid for two-dimensional layouts where rows and columns both matter; flexbox for one-dimensional distribution. Both are on this site.

Grid or flexbox — when which?

Grid for two-dimensional layout — page structures, card arrangements with alignment across rows and columns. Flexbox for one-dimensional distribution — navbars, button groups, centering. Real layouts use both: grid outside, flex inside items.

What does 1fr actually mean?

One fraction of the free space after fixed tracks are subtracted — not one fraction of the container. Two 1fr columns split leftover space equally; 1fr next to 200px gets what remains after 200px.