Build a CSS flexbox layout visually and get clean, copy-paste CSS — no manual property lookups, no guesswork.
This flexbox generator lets you set container properties like flex-direction, flex-wrap, and justify-content from simple dropdowns, drag items around to reorder them, and fine-tune individual items with flex-grow, flex-shrink, flex-basis, and align-self. The preview updates instantly, and the generated CSS is ready to paste straight into your stylesheet.
Container
Live Preview — drag items to reorder
How It Works
The tool splits flexbox into the two places its properties actually live: the container and the items inside it.
Container-level settings — display, flex-direction, flex-wrap, justify-content, align-items, align-content, and gap — control how the whole group of items behaves: which direction they flow in, whether they wrap to new lines, and how extra space is distributed.
Item-level settings apply to one flex item at a time. Click any box in the preview to select it, then adjust its flex-grow, flex-shrink, flex-basis, or align-self independently of the others. Dragging an item to a new position in the preview updates its order value automatically, so visual reordering and the CSS order property always stay in sync.
By default, only the container CSS is included in the output, since most layouts only need that. Turning on Include per-item CSS adds nth-child rules for any item that has a non-default value.
Use Cases
- Navigation bars — align a logo, links, and a CTA button in one row using
justify-content: space-betweenandalign-items: center. - Card grids and galleries — use
flex-wrap: wrapwith a fixed or flexibleflex-basisper card so items reflow cleanly at any screen width. - Centering content — a common flexbox use case solved with a single
justify-content: center; align-items: center;pairing, without extra markup or absolute positioning. - Responsive layouts — combine
flex-wrapwith per-itemflex-grow/flex-shrinkto let sections expand or shrink gracefully as the viewport changes, instead of hardcoding breakpoints.
Frequently Asked Questions
What’s the difference between flexbox and CSS grid?
Flexbox lays items out along a single direction — a row or a column — and is best for distributing space among items in that one axis, like a nav bar or a button group. CSS grid works in two dimensions at once, defining both rows and columns, and suits full page layouts or gallery-style grids. Many “flexbox grid” searches are actually describing wrapped, multi-row flex layouts, which this tool handles with flex-wrap.
What does the drag-and-drop feature actually change?
Dragging an item to a new position in the preview reorders it visually and sets its CSS order property to match, without you needing to type or track order values manually. The underlying HTML order in your markup doesn’t change — only the visual order, controlled by CSS.
Do I need to write per-item CSS for every layout?
No. Most layouts only need the container rule (the display: flex block). Per-item CSS — using flex-grow, flex-shrink, flex-basis, or align-self — is only necessary when individual items need to behave differently from their siblings, like one card in a row being wider than the rest.
How do flex-grow, flex-shrink, and flex-basis work together?flex-basis sets an item’s starting size before any extra space is distributed. flex-grow determines how much of the remaining free space an item should absorb relative to its siblings. flex-shrink determines how much an item should shrink relative to its siblings when there isn’t enough room. Together, they decide how flexible — or fixed — each item is.
Is flexbox supported in all browsers?
Yes. Flexbox has full support across all modern browsers, including Chrome, Firefox, Safari, and Edge, and has for years. No vendor prefixes or fallbacks are needed for standard flexbox properties.
Can I use this for a WordPress theme’s custom layout?
Yes. The generated CSS is plain, framework-free CSS that works in any WordPress theme — paste it into your theme’s Additional CSS panel, a child theme’s stylesheet, or a block’s custom CSS field, and target it to your own class names.
