Skip to content
MewixMewix

Flexbox generator

Change direction, main-axis alignment, cross-axis alignment, gap, and wrapping on a four-item row while the preview updates instantly.

Updated by the Mewix team

Center a div with flexbox

Horizontal and vertical centring is the usual reason people reach for flexbox on a single row. Set display: flex, pick justify-content: center for the main axis and align-items: center for the cross axis when direction is row. Swap which property feels “horizontal” when you switch to column—main axis follows direction.

justify-content versus align-items

PropertyAxis it moves on (row direction)Values available here
justify-contentHorizontal (main)flex-start, center, flex-end, space-between, space-around, space-evenly
align-itemsVertical (cross)stretch, flex-start, center, flex-end
gapBetween items0–40 px

The preview uses four labelled boxes so you can see wrapping when flex-wrap: wrap is enabled. Copied CSS targets a class named .row—rename to match your markup.

Does this set flex on children?

No. Only the container properties appear in the output. Child flex values such as flex: 1 or align-self are outside the playground.