Skip to content

CSS Flexbox Playground

Developer Tools ·
·

Play with flex-direction, justify-content, align-items, wrap, and gap. Add or drop items, watch the layout shift live, then copy the container CSS.

What this playground is for

Flexbox makes sense the moment you watch boxes move. Reading the spec doesn’t do that. This page hands you the six properties that matter most on a flex container, wires them to a row of live items, and shows the exact CSS you’d paste into a stylesheet. Click space-between, the items spread apart. Switch to column, they stack. The preview never lies.

You control flex-direction, justify-content, align-items, align-content, flex-wrap, and gap. Add items up to twelve, remove them down to one. That’s enough to reproduce the layout problems you actually hit: a navbar, a centered hero, a card grid that wraps.

The properties, untangled

People mix up the two alignment axes constantly, so here’s the short version. justify-content moves items along the main axis. align-items moves them along the cross axis. The catch? The main axis flips depending on flex-direction. In a row, justify is horizontal. Switch to column and justify goes vertical. That single rule explains most flexbox confusion.

A few notes on the rest:

  • flex-wrap decides whether items spill onto new lines or squeeze onto one. Set it to wrap and watch nine items break into rows.
  • align-content only does anything once there are multiple lines. With nowrap, it’s dead weight, so the playground hides it from the output until wrapping is on.
  • gap is the clean way to space items now. No more margin hacks on every child.

How to drive it

Pick a preset if you want a head start. “Navbar” gives you three items pushed apart with space-between. “Wrapping cards” drops nine items in a grid that reflows. From there, tap any chip to change a property and the boxes rearrange instantly.

The plus and minus buttons next to the preview change how many items you’re laying out. This matters more than it sounds. space-around with three items looks nothing like space-around with eight. Test the count you’ll really ship.

When the layout’s right, hit Copy or grab the .css file. The output is just the container rules, ready to drop onto any div.

Worth knowing

The items here use varied heights on purpose. That’s the only way align-items: flex-start versus center versus baseline shows a visible difference. Real content has uneven heights too, so this mirrors reality better than a row of identical squares would.

One honest limitation: this builds the container, not the children. Properties like flex-grow, flex-shrink, and align-self live on individual items and aren’t part of what gets generated here. For the vast majority of layouts you won’t miss them. Equal items, a justify rule, and a gap handle a huge slice of real-world flex.

Questions people ask

What’s the difference between justify-content and align-items? Justify works along the main axis, align works along the cross axis. In a row that means justify is left-to-right and align is top-to-bottom. Flip to a column and they swap. Same properties, axes rotated.

Why isn’t align-content doing anything? It only kicks in when items wrap onto more than one line. Turn flex-wrap to wrap and add enough items to force a second row, then it takes effect. That’s why the tool hides it from the CSS while you’re on nowrap.

How do I center a single element both ways? Set justify-content: center and align-items: center. The “Center everything” preset does exactly that. Works the same whether the direction is row or column.

Can I use gap with flexbox safely? Yep. Every browser people still target supports gap on flex containers. It replaced the old margin-on-each-child approach and there’s no reason to go back.

Does anything get uploaded? Nope. The CSS is assembled in your browser as you click. Nothing leaves the page, nothing’s saved anywhere.

css flexbox layout playground frontend

Related Tools

CSS Grid Generator

Developer Tools

Build a CSS grid visually. Set columns, rows, gaps, and fr/px/auto track sizes, watch the cells update live, then copy the grid CSS.

CSS Animation Generator

Developer Tools

Build CSS keyframe animations with 10 presets, fade, slide, pulse, shake, bounce, spin, wiggle, pop, and tune duration, easing, count, direction.

CSS Border Radius Generator

Developer Tools

Visual border-radius builder, independent corners, px or % unit, instant preview, copy-ready CSS.

CSS Box Shadow Generator

Developer Tools

Build any CSS box-shadow visually with sliders for offset, blur, spread, and color, with instant preview and copy-ready output.

CSS Specificity Calculator

Developer Tools

Paste a CSS selector and get its specificity as (a,b,c) with a full breakdown of which IDs, classes, and elements scored where.

CSS to Tailwind Converter

Developer Tools

Paste plain CSS and get equivalent Tailwind utility classes back. Common properties map to named classes; anything else falls back to arbitrary values.

CSS Triangle Generator

Developer Tools

Build a pure-CSS triangle with the border trick. Pick a direction, set the size and color, and copy the ready-to-use code. Eight directions supported.

Cubic Bezier Generator

Developer Tools

Drag two control points to shape a CSS easing curve, watch it animate live, and copy the cubic-bezier() value. Six presets including overshoot.

Code Formatter

Developer Tools

Format and beautify JSON, HTML, CSS, XML, and SQL code with customizable indentation

More in Developer Tools