CSS Flexbox Generator

Visually configure a Flexbox container and its items, preview the layout in real time, and copy the generated CSS instantly.

Container Properties

Live Preview

Item Properties (per child)

Generated CSS

How It Works

Flexbox lays out children along a main axis (set by flex-direction) and aligns them on a cross axis. justify-content distributes space along the main axis, while align-items controls the cross axis. flex-wrap decides whether items break to new lines when they overflow, and gap adds uniform spacing between siblings. Each item can override the cross-axis alignment with align-self, tune growth/shrink ratios via flex-grow and flex-shrink, set a preferred base size with flex-basis, and reorder visually through order. This tool maps your choices directly to these standard CSS declarations.

Frequently Asked Questions

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

justify-content aligns items along the main axis (horizontal by default), controlling how space is distributed between them. align-items aligns items along the cross axis (vertical by default), controlling how they stack within each line.

How do flex-grow, flex-shrink, and flex-basis work together?

The shorthand flex: grow shrink basis defines how an item behaves. flex-basis is the starting size, flex-grow specifies how much of the remaining space the item claims, and flex-shrink controls how much it shrinks when space is tight.

Why are my flex items not wrapping to the next line?

By default, flex-wrap is set to nowrap, so items stay on one line even if they overflow. Set flex-wrap: wrap (or wrap-reverse) on the container, and optionally add a gap or reduce item sizes so wrapping happens as expected.

Related Tools

Copied to clipboard