CSS Flexbox Generator
NEWExperiment with flex container and item properties visually and copy the flexbox CSS.
Runs 100% in your browser — your input is never uploaded or stored on our servers.
.container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: stretch;
gap: 12px;
height: 220px;
}
.item {
padding: 16px;
box-sizing: border-box;
}
.item-1 {
height: 60px;
}
.item-2 {
height: 100px;
}<div class="container">
<div class="item item-1">1</div>
<div class="item item-2">2</div>
<div class="item item-3">3</div>
</div>Quick Examples
Typical inputs and the results this tool produces.
Overview
Flexbox is the CSS layout model for arranging items in one dimension, a row or a column, with control over alignment, spacing and how items grow or shrink to fill the space. Its many properties are easy to confuse: justify-content works along the main axis, align-items along the cross axis, and align-content only matters when items wrap onto several lines.
This CSS flexbox generator lets you change every container property (flex-direction, flex-wrap, justify-content, align-items, align-content, gap) and every item property (flex-grow, flex-shrink, flex-basis, align-self, order, width, height) and see the result immediately in a live preview. Add or remove items, click one to edit it, and copy the matching CSS and HTML when the layout looks right.
Everything runs in your browser and the preview is real flexbox rendered by your own browser, so what you see is exactly what the copied code does. Use the presets (centered, navbar, sidebar, wrapping cards, column stack) as starting points for common patterns.
Why use this tool?
- See the effect of every flexbox property live
- Per-item grow, shrink, basis, align-self and order
- Copy clean CSS and matching HTML in one click
- Presets for centering, navbars, sidebars and card grids
- Validates values and explains mistakes
Features
All container properties
Direction, wrap, justify-content, align-items, align-content and gap.
Per-item controls
Set flex-grow, flex-shrink, flex-basis, align-self, order, width and height for each item.
Live preview
Rendered by your browser with real flexbox, so it always matches the code.
Add and remove items
Test layouts with 1 to 12 items and click any item to edit it.
Presets
Start from centered, navbar, sidebar, wrapping cards or column stack.
CSS and HTML export
Only non-default item declarations are emitted, keeping the CSS short.
How to Use
Pick a preset or start fresh
Choose a preset layout, or change the container settings directly.
Tune the container
Set direction, wrap, justify-content, align-items, align-content and gap.
Edit the items
Add items, click one in the preview and adjust grow, shrink, basis, align-self and order.
Copy the code
Copy the CSS and HTML and paste them into your project.