Start a project

Tool 08 of 29 · Layout

Grid & Flexbox Playground

Lay out a page with CSS Grid or Flexbox by changing settings and watching the preview, then copy the CSS and HTML it writes for you.

Grid & Flexbox Playground

Container

Selected item: Item 1

Click or tab to an item in the preview to select it.

Preview

Your code

CSS
HTML

01

What it does

Build Grid and Flexbox layouts visually, set spans and flex values per item, and copy the CSS and HTML.

  • Fixed, auto-fill and custom column templates
  • Gaps, alignment and dense packing
  • Per-item column and row spans
  • Flex direction, wrap, grow, shrink and basis

02

Private by design

Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

03

What you get

CSS and HTML, with a Copy and a Download button on every result.

  • CSS Grid
  • Flexbox
  • Layout

Why it matters

Grid and Flexbox replaced floats and frameworks for layout years ago, and every current browser supports both. But the properties are easy to mix up: justify-items or justify-content, auto-fill or auto-fit, and which ones belong on the container rather than the items.

Seeing the result as you change each setting is the quickest way to learn them, and the fastest way to get a tricky layout right. The code this writes is plain CSS with no framework, ready to paste.

How to use it

  1. Choose CSS Grid or Flexbox, or start from a preset.
  2. Set the columns, rows, gaps and alignment for the container.
  3. Select an item in the preview to change its span or flex values.
  4. Copy or download the CSS and HTML.

FAQ

What's the difference between auto-fill and auto-fit?

Both fit as many columns as there's room for. With only a few items, auto-fill keeps the empty column tracks, so items stay their minimum size; auto-fit collapses them, so items stretch to fill the row. This tool writes auto-fit with min(220px, 100%), so a single card never overflows a narrow phone.

When should I use Grid rather than Flexbox?

Use Grid when you're placing things in rows and columns at the same time, like a card grid or a page layout. Use Flexbox for one row or column of things, like a navigation bar or a row of buttons.

What does dense do?

grid-auto-flow: dense lets later, smaller items fill gaps left by bigger ones. It can change the visual order, so keep the HTML order sensible for keyboard and screen reader users.

Does it work on phones?

Yes. The preview scrolls sideways if your layout is wider than the screen.

Work with me

Want a site that gets these right?

I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

All developer tools · Back to leej.uk