ShareYourGroupShareYourGroupCSS Lab

CSS flexbox generator

Flexbox lines items up in one direction. Change a property and watch the boxes move.

The two axes

Everything in flexbox depends on two directions. The main axis is the direction items are laid out in, set by flex-direction: row runs left to right, column runs top to bottom, and the two -reverse values flip it. The cross axis is the other direction.

PropertyWorks alongWhat it does
justify-contentmain axisSpreads items along the line: start, centre, end, or with space between, around or evenly
align-itemscross axisPlaces each item across the line: stretch (the default), start, centre, end or on a text baseline
align-contentcross axisOnly matters when items wrap onto several lines: how the lines sit in the container
gapbothSpace between items, without margins on the items
flex-wrapWhether items stay on one line or wrap onto more

Reading the preview

The boxes have different sizes on purpose, so you can see what stretch and baseline do. If you choose column, the container needs a height for justify-content to have anything to spread, which is why the preview box has a fixed height. In your own page, a column container with no set height is only as tall as its content.

Common mistakes

Does gap work in flexbox on all browsers?

We tested it in current Chrome and WebKit on 13 November 2026 and it worked in all three. Very old browsers may not support it.

What is the difference between space-around and space-evenly?

Space-around gives each item the same space on both sides, so the gaps between items are twice the gap at the ends. Space-evenly makes every gap the same, including the ends.

This is an independent site. It is not connected with the W3C, MDN, Google, Apple, Mozilla or Microsoft. Browser and product names belong to their owners.