Skip to content

Flexbox Playground

Toggles every flex property on a live example and shows the CSS and what each property changed.

Every flexbox property on a live example, with a line under each control saying what it actually does. The preview is the browser’s own flex layout and the CSS is that state written down, so what you see is what your page will do.

🔒 Runs entirely in your browsercssflexboxlayoutlearn

Preview

Click an item to edit its own properties on the right.

Container

Item 1

Code

Output
  • · The main axis runs horizontally.
  • · Every flex-grow is 0, so justify-content is what divides the spare space.

Properties left at their default are not written out. Only what you changed appears.

The preview is the browser’s own flexbox and the CSS is that state written down, so what you see here is what the page will do. For a two-dimensional layout, go to the CSS grid generator.

How to use it

  1. Set the container properties

    Direction, wrapping, and the three alignment properties. Each has a sentence under it explaining what it changes — `align-content` in particular does nothing at all with a single line.

  2. Click an item to edit it

    Grow, shrink, basis, align-self and order apply to one item. Add and remove items to see how the container redistributes.

  3. Read the notes and copy the CSS

    The panel describes what your current layout will actually do, and the output omits every property still at its default — so what you copy is only what you changed.

Common questions

Why does my item overflow instead of shrinking?

Either `flex-shrink: 0`, or a child with a minimum content size. A flex item’s `min-width` defaults to `auto`, which means it will not shrink below its content — a long unbroken string or a wide image is the usual culprit. `min-width: 0` is the fix.

What is the difference between `align-items` and `align-content`?

`align-items` places each item on the cross axis. `align-content` places the *block of lines* when wrapping has produced more than one — so with `nowrap`, or with a single line, it does nothing whatsoever. That is the most common source of "this property is broken".

Should I use `order` to rearrange things?

Sparingly. It changes the visual order and not the DOM order, so screen readers and tab order still follow the markup. A keyboard user tabbing through a visually reordered layout jumps around the screen — which is why the spec calls it a last resort.

Flexbox or grid?

Flexbox for one dimension — a row of buttons, a toolbar, a card’s internals. Grid when rows and columns have to line up with each other. If you are nesting flex containers to fake a grid, you want a grid.

Feed it from

Next

These accept what this tool produces, so the result can go straight in.