Flexbox Playground

Visually build a CSS flexbox layout and copy the exact HTML and CSS.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

The Flexbox Playground turns CSS flexbox from guesswork into something you can see. Instead of editing a stylesheet, refreshing, and squinting at the result, you adjust every flexbox property with visual controls and watch a row of live boxes rearrange in real time. When the layout looks right, you copy clean, ready-to-paste HTML and CSS and drop it into your project. Everything happens in your browser — there is no build step, no account, and nothing is uploaded.

Most online flexbox tools only expose the container properties. This one goes further: alongside flex-direction, flex-wrap, justify-content, align-items, align-content and the gap, you can click any individual box and tune its per-item behaviour — flex-grow, flex-shrink, flex-basis, align-self and order. That second layer is exactly where flexbox usually gets confusing, so being able to isolate one item and watch only it respond makes the mental model click. It is equally useful as a teaching aid and as a fast scaffolding tool for real component layouts.

How it works

A flex container has two axes. The main axis runs in the direction set by flex-direction (horizontal for row, vertical for column), and the cross axis is perpendicular to it. justify-content distributes items along the main axis; align-items aligns them on the cross axis; and align-content spaces multiple wrapped lines — which is why it only matters once flex-wrap is on. The playground mirrors these rules: enable wrapping and the align-content control wakes up, flip the direction and the two alignment controls quietly swap which physical axis they govern.

Per item, flex-basis sets a starting size, then flex-grow shares out spare space and flex-shrink reclaims space under pressure. Select a box and the tool shows the resulting flex: grow shrink basis shorthand it will emit. When you export, it writes a .flex-container rule plus a :nth-child() rule for every item you actually customised — never noise for properties left at their defaults.

Example

Suppose you want a typical navigation bar: a logo pinned left, links pinned right, everything vertically centred. Load the Navbar preset (justify-content: space-between, align-items: center) and you are most of the way there. Now click the last box and set its flex-grow to 1 to let a search field stretch and fill the middle. Press Copy HTML + CSS and you get something like:

.flex-container {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.flex-container > :nth-child(4) {
  flex: 1 1 auto;
}

Paste that with the matching markup and the layout behaves exactly as it did in the preview — a real, working flexbox component, built by sight in under a minute. Your current arrangement is auto-saved to this browser, so you can close the tab and pick up where you left off.

Ad placeholder (rectangle)