Type a tool name, for example "keyword density" or "transcript".
Visually build CSS Flexbox layouts with live preview and code output.
This flexbox generator lets you build a CSS flexbox layout visually: pick direction, wrap, alignment and gap, watch numbered boxes rearrange in a live preview, and copy the finished container CSS. It suits beginners learning flexbox and developers who want a quick starting point for navbars, card rows and centered content.
Flexbox, formally the CSS Flexible Box Layout Module, is a layout model that arranges child elements in a single row or a single column and controls how they share space. You turn it on by setting display: flex on a parent element. Its direct children then become flex items.
Everything in flexbox revolves around two axes. The main axis runs in the direction set by flex-direction (horizontal for row, vertical for column). The cross axis runs perpendicular to it. The justify-content property aligns items along the main axis, and align-items aligns them along the cross axis. Change the direction and the two properties swap roles, which is the part most beginners find confusing.
Flexbox handles one dimension at a time. When you need rows and columns together, such as a page grid with cells aligned in both directions, CSS Grid is the better fit. Many layouts use both: Grid for the page frame and flexbox for the components inside it.
You build a layout by changing dropdowns and sliders, and the preview updates on every change. Follow these steps:
Say you want a header where a logo sits on the far left, links sit on the far right and everything is vertically centered. Set flex-direction to row, flex-wrap to nowrap, justify-content to space-between, align-items to center and gap to 16. Leave Number of Items at 4 so you can see four boxes spread across the bar.
The Generated CSS box then shows a .container rule with display: flex, flex-direction: row, flex-wrap: nowrap, justify-content: space-between, align-items: center, align-content: normal and gap: 16px. In the preview, box 1 touches the left edge, box 4 touches the right edge, and boxes 2 and 3 sit evenly between them with at least 16 px of space around each.
To read this result: space-between puts the first and last items against the container edges and splits the leftover space between the rest. If you wanted equal space at the edges too, switch to space-evenly and compare the preview. Then rename .container to your real class, such as .site-header, and apply it to the parent element.
The preview shows exactly what each property does, and the CSS box gives you the matching declarations. This table summarizes the controls and when each one is the right choice.
| Control | What it affects | Typical use |
|---|---|---|
| flex-direction | Main axis direction | Row for toolbars, column for stacks |
| justify-content | Spacing along main axis | space-between for navbars, center for buttons |
| align-items | Alignment across the axis | center for icon plus text rows |
| flex-wrap | Single or multiple lines | wrap for card lists and tag clouds |
| align-content | Spacing between wrapped lines | Tall containers with several lines |
| gap | Space between items | Consistent spacing without margins |
Align-content only works when there is more than one line of items. With nowrap, all boxes stay on one line, so changing it has no visible effect. Switch flex-wrap to wrap, raise Number of Items to 10 or 12, and shrink the layout until the boxes break onto a second row. Now the option shows its effect.
Stretch, the default, makes items as tall as the container (in a row) unless they have their own height. If your boxes look oddly tall, choose flex-start or center. Baseline lines up the text baselines of items, which helps when items have different font sizes.
Most common flexbox questions are answered by one property or one item-level rule. Use these quick fixes after you copy the container CSS.
flex: 1 to each child in your own CSS so they share the space equally.flex: 1 to the item that should grow.It helps anyone who wants to see flexbox rules in action before committing them to code. Typical situations include:
Once the layout is set, polish the pieces inside it with the border radius generator for rounded cards and the CSS box shadow generator for depth.
A few habits prevent most flexbox surprises. Build with the preview first, then test the copied CSS in your real page, because your content will differ from the numbered boxes.
The generator writes the container rule only. It does not output item-level properties such as flex-grow, flex-shrink, flex-basis, order or align-self, and it does not create the HTML for your items. You add those in your own code when a single child needs special treatment.
The Container Height slider sizes the preview so you can judge vertical alignment. The copied CSS does not include a height declaration, so set one yourself on the real container when your layout needs it. The preview boxes are numbered placeholders with a minimum size of 40 px, so real content with different sizes will space out differently. Treat the result as an accurate starting point and adjust once your actual content is in place.
Open the generator above, set your direction, wrap and alignment, and copy the CSS when the preview looks right. For more helpers like it, browse the web developer tools collection.
Your report has been submitted. We will look into this issue.
A VPN changes your network exit. It does not guarantee anonymity.
Themes, plugins, code, video, audio, graphics & more from 90,000+ authors.
Web Development
Design & Media
Unlimited Access
Explore Envato Market