CSS

Flexbox Generator

Configure a flex container visually and copy the CSS.

flex-direction

justify-content

align-items

flex-wrap

12px

Items

4
Preview
1
2
3
4

Item heights vary so align-items is visible. Everything renders in your browser.

CSS
.container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

How it works

Flexbox is a one-dimensional layout model: a display: flex container arranges its direct children along a single axis. The flex-direction sets that axis, and two properties then position the items — justify-content along the main axis and align-items along the cross axis.

Set those values with the segmented controls, add a gap, and toggle flex-wrap to decide whether items reflow on narrow screens. The preview boxes are intentionally different heights so the cross-axis alignment is actually visible, and you can add or remove items to test how the container responds.

The CSS panel is the source of truth — copy it and paste it onto any wrapper element whose direct children should become flex items. Everything is computed in your browser; there is no network call and no dependency to install.

Frequently asked

How do I use this flexbox generator?+

Pick a flex-direction, then set justify-content (the main-axis distribution) and align-items (the cross-axis alignment), choose whether items wrap, and drag the gap. The preview updates live and the CSS in the panel is exactly what you copy — no build step and nothing is sent anywhere.

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

They act on different axes. justify-content positions items along the main axis — the direction set by flex-direction (a row runs left-to-right, a column runs top-to-bottom). align-items positions items along the cross axis, perpendicular to it. Because they swap meaning when you switch between row and column, the live preview is the fastest way to see which one you actually need.

How do I center a div with flexbox?+

Set the container to display: flex, then justify-content: center and align-items: center. That centers a child on both axes regardless of its size. Select those two values here and copy the generated CSS — it is the canonical, dependency-free way to center content.

When should I use flex-wrap?+

Use flex-wrap: wrap when items should flow onto new lines instead of shrinking or overflowing on narrow screens — card grids and tag lists are the common cases. With the default nowrap, flex items stay on one line and compress to fit. Toggle it here to see the difference at small widths.

Does the copied CSS need any framework?+

No. The output is plain CSS Grid… flexbox properties on a .container class — no Tailwind, no library, no dependencies. Paste it into any stylesheet and apply the class to a wrapper whose direct children are the flex items.

Is anything I enter sent to a server?+

No. The generator runs entirely in your browser — the preview and the CSS are computed locally, so you can use it offline and nothing you configure leaves the page.

More free tools

All tools

More tools shipping weekly.

Lay it out, then get it reviewed

This tool shows your layout change the instant you make it. Shotline does the same for feedback — clients drop comments straight on the live page, each pinned to the exact element, so “this box is misaligned” arrives with the selector attached.

No signup needed. Free demo canvases stay live for 72 hours.

or start your 14-day free trial — no card required.

Shotline — Flexbox Generator — free, in-browser