CSS Generators

Flexbox Generator

All tools

Try every flex alignment combination on real boxes and copy the container rule that matches.

How it works

Four simple steps

1

Set the direction

Choose row, column or a reversed direction for the main axis.

2

Align the boxes

Pick justify-content and align-items from the dropdowns.

3

Tune wrap and gap

Decide whether items wrap and drag the gap between 0 and 48 px.

4

Copy the container rule

Copy the .container CSS or download it as flex.css.

Flexbox Generator

About Flexbox Generator

You want three cards spaced evenly across a row on desktop and stacked on mobile, and you can never remember whether that is justify-content or align-items. Rather than reload the browser twenty times, set the values here and watch the boxes respond.

The generator controls the flex container. Pick justify-content (flex-start, center, flex-end, space-between, space-around or space-evenly), align-items (stretch, center, flex-start, flex-end or baseline), flex-direction (row, row-reverse, column or column-reverse) and flex-wrap (nowrap, wrap or wrap-reverse), then set gap from 0 to 48 px. Three numbered boxes in the preview rearrange on every change, and the output is a single .container rule with display: flex and those five properties.

The usual source of confusion is direction. justify-content always works along the main axis, so once you switch to column it controls vertical spacing and align-items takes over horizontally. Test that switch in the preview before you write a media query. Properties on the children, such as flex-grow or order, are not part of this tool. When the layout is really two-dimensional, the CSS grid generator is the better starting point, and for spacing tokens shared across rows and stacks see the gap and spacing snippet tool.

The CSS is assembled in the page as you change the controls, so you can copy or download flex.css right away.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

In a column the main axis is vertical, so space-between needs spare height to distribute. If the container is only as tall as its content there is nothing to share. Give the container a height or min-height.

No. The generator only writes container properties. Add flex: 1 or similar rules to the children yourself.

Yes. Flex gap is supported in all current versions of Chrome, Edge, Firefox and Safari. Only very old Safari releases (before 14.1) ignore it.

View more FAQs

Related tools

View all

Tailwind Class Sorter

Sort Tailwind classes and detect conflicting utilities with a winner explanation.

Open

Design System Diff Lab

Diff design tokens and inspect CSS @layer order and selector specificity locally.

Open

SVG Path Inspector

Parse SVG path commands, preview on canvas, round and minify coordinates.

Open

Grid Generator

Build grid layouts visually.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools