Flexbox

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.

Back

1. Container

.flex-container

2. Live preview

Uses the generated CSS

3. Items

Up to 12

Generated code

Same CSS as the preview

Item 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 this tool

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.

How to use

Step by step

  1. Set the container properties, such as direction, wrapping and justify-content.
  2. Adjust gaps, width, height, padding and background.
  3. Edit the sample items — label, order, grow, shrink, basis and align-self.
  4. Add, remove or reorder items with the buttons on each card.
  5. Watch the live preview update as you go.
  6. Copy or download the CSS and HTML.
Key features

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
Best practices

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.
Benefits

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.

FAQ

Common questions

Yes. The CSS shown below the preview is applied to the preview itself (scoped to it), so the layout you see is the layout the code produces.
align-content only affects flex containers whose items wrap onto several lines. With flex-wrap: nowrap it has no effect, so it is left out; choose wrap to include it.
flex: 1 1 200px means flex-grow 1, flex-shrink 1 and flex-basis 200px. Items with the default 0 1 auto get no flex rule at all, keeping the CSS short.
Widths, heights, gaps, padding and flex-basis accept numbers with px, %, em, rem, vw, vh or ch. Width, height and basis also accept auto (and basis accepts content). Invalid values are highlighted and not used.
No. order only changes the visual order; the HTML keeps the source order, which is what screen readers and keyboard users follow. Use the ↑ and ↓ buttons to change the real order.
Yes. Labels are shown as plain text in the preview and HTML-escaped in the generated markup.
The properties used — flexbox and the gap property for flex containers — are supported by all current major browsers. Very old browsers (such as Internet Explorer) do not support flex gap.
Private by design

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.

Install Toolisco Add it to your device for offline, one-tap access.