Free CSS Flexbox Playground

Free CSS flexbox playground: set flex-direction, wrap, justify-content, align-items, gap and per-item grow, shrink, basis and order, then copy the CSS code.

  • No upload, 100% private
  • Instant, in your browser
  • 100% free, no signup
Loading tool…
Read the complete guideCSS Flexbox Explained, From justify-content to flex-grow →

About the Flexbox Playground tool

Flexbox is the go-to CSS tool for aligning items in a row or column, but the difference between justify-content and align-items, or between flex-grow and flex-basis, is much easier to understand by seeing it. This flexbox playground lets you change every property and watch the boxes move.

On the container you can set flex-direction, flex-wrap, justify-content, align-items, align-content and gap. Select any item to change its flex-grow, flex-shrink, flex-basis, order and align-self, and add up to twelve items. Items use different font sizes so baseline alignment is visible, and items with a custom order are labelled. The preview container can be resized by dragging its corner and its height adjusted with a slider, so you can see how wrapping and alignment react to available space.

Presets load common patterns such as centring an element, a navbar with a stretching middle, equal-width columns, a fixed sidebar with fluid content, wrapping cards and a vertical stack. The generated CSS updates live, including nth-child rules for items you have customised, alongside the matching HTML structure. Copy it or download it as a .css file.

How to use Flexbox Playground

  1. Change the container properties in “Container (flex parent)” and move the “gap” slider.
  2. Click an item number, in the list or in the preview, to select it.
  3. Adjust “flex-grow”, “flex-shrink”, “order”, “flex-basis” and “align-self” for that item.
  4. Try a preset such as “Center everything” or “Sidebar layout” for a starting point.
  5. Copy the “Generated CSS” and “HTML structure” into your project.

Features

All container properties

Direction, wrap, justify-content, align-items, align-content and gap.

Per-item controls

Grow, shrink, basis, order and align-self for each of up to 12 items.

Layout presets

Six real-world patterns including navbar, equal columns and sidebar layouts.

Resizable preview

Drag the preview width and set its height to test wrapping and alignment.

Clean CSS output

Only non-default values are written, with nth-child rules for customised items.

When to use it

  • Learn flexbox visually while studying CSS layout.
  • Work out the right properties to centre something vertically and horizontally.
  • Prototype a navigation bar or card row before writing the real CSS.
  • Explain the difference between justify-content and align-items to a colleague.
  • Debug why items are not wrapping or growing as expected.

Frequently asked questions

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

justify-content distributes items along the main axis (horizontal in a row), while align-items aligns them on the cross axis (vertical in a row). Swapping flex-direction to column swaps the axes.

Why does align-content do nothing?

align-content only affects containers whose items wrap onto more than one line. Set flex-wrap to wrap and add enough items or reduce the width.

What does flex: 1 mean?

It is shorthand for flex-grow: 1, flex-shrink: 1 and flex-basis: 0%, so items share the free space equally. The Equal columns preset shows this.

Should I use flexbox or CSS grid?

Flexbox is best for one-dimensional layouts such as rows of buttons or navbars. Grid is better when you need rows and columns aligned together.

Does the generated CSS work in all browsers?

Yes. The flexbox properties and gap used here are supported in all current browsers.

Related tools