CSS Flexbox Playground

Live flexbox playground. Pick flex-direction, justify-content, align-items, gap, flex-wrap; see results immediately on real boxes. Add or remove items to test how the container behaves. Copy the generated CSS.

How to use the CSS Flexbox Playground

Adjust any control to see the flex container rearrange. Boxes have varied widths/heights so you can see the effect of align-items clearly. Output is the complete display: flex rule for the container.

Flexbox, learned by moving the controls

Flexbox lays items out along a single axis, and most of the confusion comes from the interplay of its properties: justify-content distributes space along the main axis, align-items positions on the cross axis, and the meaning of both flips when you switch flex-direction from row to column. Reading the spec rarely makes this click; watching boxes move does.

Change any control here and the container rearranges live, with varied box sizes so the alignment effects are obvious, then copy the finished rule. When your layout needs two dimensions — rows and columns together — reach for the grid generator instead, and the grid-to-flex converter shows the two approaches to the same layout side by side.

Common use cases

  • Navigation bars — space links with justify-content and center them vertically.
  • Centering — settle the classic center-a-box problem in one rule.
  • Toolbars — push actions to opposite ends with space-between.
  • Wrapping chips — let tags flow onto new lines with flex-wrap.
  • Learning flexbox — see exactly what each property does before committing.

Frequently asked questions

When should I use flexbox over grid?

Flexbox suits one-dimensional layouts — a row or a column. For two-dimensional layouts with aligned rows and columns, use CSS grid.

Why do justify-content and align-items swap?

They act on the main and cross axes, which rotate when flex-direction changes from row to column, so their visual effect swaps.

What does the copied CSS include?

The full display: flex rule for the container with every property you set, ready to paste.

Where can I build a grid version?

Use the grid generator, or compare both in the grid-to-flex converter.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: