CSS Flexbox Generator with Live Preview

Build a CSS flexbox layout — flex-direction, justify-content, align-items, flex-wrap, gap, align-content, plus per-item order, grow, shrink, basis, align-self.

display Details
flex-direction Details
justify-content Details
align-items Details
flex-wrap Details
align-content Details

align-content needs flex-wrap: wrap or wrap-reverse. With nowrap there is a single line and nothing to line up, so it is left out of the CSS below.

Live preview

1
2
3

Click an item to give it a size and a place of its own.

display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
gap: 8px;

🔒 Generated in your browser — nothing is uploaded.

What this flexbox generator does

CSS flexbox is the one-dimensional layout model that lets a container arrange its children along a row or a column. Pick a value for each core property — flex-direction to set the main axis, justify-content to distribute items along it, align-items to line them up across it, flex-wrap to allow or prevent wrapping, and a gap in pixels for the spacing between items. Turn wrapping on and align-content decides where the wrapped lines sit across the container. Set how many items the preview holds, then give any one of them its own order, flex-grow, flex-shrink, flex-basis and align-self. A live preview of numbered boxes reflows instantly with every change, so you can see exactly how each property behaves before you copy the code.

Copy-ready CSS output

The tool prints a ready-to-paste declaration block that starts with display: flex — or display: inline-flex when you pick that — and then lists your chosen flex-direction, justify-content, align-items, flex-wrap, then align-content when wrapping is on (on nowrap it does nothing, so it is left out), then gap. Under that comes one .item-N rule for every item you gave settings of its own, and nothing at all for the ones you left alone. Drop the block straight into a class in your stylesheet or an inline style attribute on the container element. The output is deterministic, so the same selections always produce exactly the same CSS — handy for learning how the properties combine and for grabbing a correct starting point for any layout.

Frequently asked questions

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

justify-content distributes items along the main axis (the direction set by flex-direction), while align-items positions them along the cross axis. For a row, justify-content moves items left-to-right and align-items moves them top-to-bottom.

Why do some justify-content values look the same in my preview?

Values like space-between, space-around and space-evenly only differ visibly when items are smaller than the container and there is free space to distribute. With few items or a wrapping layout the spacing may look similar until there is room to spread them out.

Is anything I create uploaded to a server?

No. The live preview and the generated CSS are produced entirely in your browser with JavaScript. Your selections and the resulting flexbox code are never sent, stored or uploaded anywhere.