CSS Flexbox Generator
Design flexbox layouts visually and copy the CSS
Click an item in the preview to set per-item overrides.
How to Use
- Configure the container — Set display, direction, wrap, justification, and alignment with the dropdowns; the preview updates instantly.
- Tune the gap — Drag the gap slider to space items evenly without writing margin rules.
- Adjust the item count — Choose between 3 and 12 demo items to see how your layout behaves as it fills up.
- Override a single item — Click any item in the preview, then set its flex-grow, flex-shrink, or align-self to break it out of the container’s rules.
- Copy the CSS — Grab the generated
.containerand.item-Nblocks and paste them into your stylesheet. Default values are omitted, so the output stays clean.
Features
- Full container control — display, flex-direction, flex-wrap, justify-content, align-items, align-content, and gap in one place.
- Live preview — Every change renders immediately on a demo container with numbered, color-coded items.
- Per-item overrides — Select any item to give it its own flex-grow, flex-shrink, or align-self, emitted as a separate
.item-Nrule. - Clean output — Properties left at their CSS defaults are elided, so you copy only what actually changes the layout.
- 100% client-side — Everything runs in your browser; no data ever leaves your device.
Use Cases
- Navbars and toolbars: Prototype a
space-betweenheader with a centered group and check wrapping behavior before touching your codebase. - Holy-grail layouts: Combine
flex-growon a main column with fixed siblings to sketch classic multi-column page structures. - Learning flexbox: Flip one property at a time and watch the preview to build intuition for how the main and cross axes interact.
Related Tools
- CSS Box Shadow Generator — Design layered box shadows with live preview.
- CSS Gradient Generator — Build custom CSS gradients for your layouts.
- Color Palette Generator — Generate harmonious color palettes for your design.
Frequently Asked Questions
What is the difference between justify-content and align-items?
justify-content distributes items along the main axis — horizontal in a row layout, vertical in a column layout. align-items positions items on the cross axis, which runs perpendicular to the main axis. If you rotate the layout with flex-direction: column, the two axes effectively swap.
When does align-content have an effect?
align-content only matters when the container wraps items onto multiple lines (flex-wrap: wrap or wrap-reverse) and there is extra space on the cross axis. With a single line of items it does nothing — use align-items for single-line alignment instead.
What do flex-grow and flex-shrink actually control?
flex-grow determines how much of the container's leftover space an item absorbs relative to its siblings: an item with flex-grow: 2 expands twice as much as one with flex-grow: 1. flex-shrink does the opposite when space runs out — higher values shrink more. Set flex-shrink: 0 to keep an item at its natural size.