CSS Flexbox Playground

Experiment with flexbox properties and copy the CSS.

Free CSS Flexbox playground — change flex-direction, justify-content, align-items, wrap and gap, watch a live preview, and copy the generated flexbox CSS. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

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

justify-content positions items along the main axis (the flex-direction), while align-items positions them along the cross axis. Swapping flex-direction swaps which axis each one controls.

CSS Flexbox playground

This is a hands-on flexbox playground that generates ready-to-paste display: flex rules. It is for developers learning flexbox or fine-tuning a row or column of items — navbars, button groups, card rows, centred hero content. Change a property, watch the preview rearrange, and copy the exact CSS.

How it works

The playground sets five container properties and writes them out as a display: flex block. flex-direction chooses the main axis (row or column, optionally reversed). justify-content positions items along that main axis; align-items positions them along the cross axis — so swapping the direction swaps which control does what. flex-wrap decides whether items stay on one line or flow onto new lines, and gap sets the spacing between items. The preview is a live flex container using the same values, with the item count adjustable so you can test crowding and wrapping.

Common layout recipes

Navbar (items pushed to edges, vertically centred):

display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 16px;

Perfect centre (single item in the middle of a container):

display: flex;
justify-content: center;
align-items: center;

This pattern works for centring a modal, a hero badge, or an icon inside a button — combine with a minimum height on the container.

Card row that wraps on smaller screens:

display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 1rem;

Child cards get a flex: 1 1 280px to set a minimum width before wrapping; the flex container then distributes remaining space among those on each line.

Vertical sidebar menu:

display: flex;
flex-direction: column;
gap: 4px;
align-items: flex-start;

justify-content values at a glance

justify-contentEnd gapsGaps between items
flex-startitems packed at startnone
centeritems packed at centrenone
flex-enditems packed at endnone
space-betweennoneequal
space-aroundhalf-sizeequal (double between)
space-evenlyequalequal

When to reach for flexbox vs grid

Use flexbox when you have a single row or column of items and want the items themselves to determine the distribution. It excels at navigation bars, button groups, form rows, and any layout where one axis is the natural primary axis.

Use CSS grid when you need precise control over both rows and columns simultaneously — product grids, page templates, dashboards where cells must align across rows and columns. Grid also makes it straightforward to place items into specific named areas.

The two can nest: a grid layout can contain flex rows inside its cells, and a flex container can hold a grid child.

Everything runs in your browser — nothing is uploaded.