CSS Flexbox Generator
Adjust the container and each sample item and watch the live preview update. The preview is styled by exactly the CSS you copy, so what you see is what you get.
1. Container
.flex-container2. Live preview
Uses the generated CSS3. Items
Up to 12Generated code
Same CSS as the previewItem colours, padding and fonts in the preview are demo styling only — they are not part of the CSS above. Download HTML gives a standalone page with the CSS and the demo styling in separate blocks.
About CSS Flexbox Generator
CSS Flexbox Generator lets you build a flexbox layout visually. You set the container’s display, direction, wrapping, justify-content, align-items, align-content, gaps, size, padding and background, and each item’s order, flex-grow, flex-shrink, flex-basis and align-self. Items can be added, removed, renamed and reordered, and the live preview is styled by exactly the CSS that the tool generates.
Flexbox is the standard way to align and distribute items in one direction, but its properties interact in ways that are easier to understand by seeing them. Experimenting visually and copying the resulting CSS is faster than trial and error in your stylesheet, and helps you learn what each property does.
Step by step
- Set the container properties, such as direction, wrapping and justify-content.
- Adjust gaps, width, height, padding and background.
- Edit the sample items — label, order, grow, shrink, basis and align-self.
- Add, remove or reorder items with the buttons on each card.
- Watch the live preview update as you go.
- Copy or download the CSS and HTML.
What it offers
- All main flex container properties
- Separate row and column gaps
- Per-item order, grow, shrink, basis and align-self
- Add, remove and reorder up to 12 items
- Live preview styled by the generated CSS
- Validation for every size value
- Clean CSS that omits default item values
- Copy and download CSS, HTML and a standalone demo page
Tips for best results
- Use the ↑ ↓ buttons, not order, when the visual order should match reading order.
- Prefer gap over margins for spacing between items.
- Use flex: 1 1 0 for equal-width columns that share space evenly.
- Turn on wrapping for rows of cards so they reflow on small screens.
- Check the result at several screen widths in your own page.
Why people use it
See it live
Every change is reflected instantly in the preview.
Accurate code
The preview uses exactly the CSS you copy.
Clean output
Only the properties you need.
Local
Runs in your browser with no sign-up.
Common questions
This runs entirely in your browser
No file or text you enter here is uploaded. Encoding and decoding happen on your device using native browser APIs — close the tab and nothing remains on a server.