Skip to content
M2TOOLKIT

CSS Flexbox Generator

See what every flexbox property does, then copy the code.

Use it as often as you like — it's free, with no sign-up and no limits.

  • Design
  • Free
  • No sign-up
  • Runs in your browser
  • Updated
12px
5

Click an item in the preview to set its own flex values.

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us.

How to use the CSS Flexbox Generator

  1. Set the container properties and number of items.
  2. Click an item to give it its own flex values.
  3. Copy the generated CSS.

What does this tool do?

Flexbox lays items out in one direction — a row or a column — and is ideal for navigation bars, button groups, cards in a row and centring. Experimenting live is the fastest way to learn how justify-content (main axis) and align-items (cross axis) interact.

Why use it?

  • Live preview.
  • Per-item controls.
  • Clean CSS output.

Use cases

  • Navigation bars, toolbars and button groups.
  • Centring content vertically and horizontally.
  • Rows of cards that wrap onto new lines on small screens.

Centre anything

.box { display: flex; justify-content: center; align-items: center; }

And a navigation bar with the logo left and links right: display: flex; justify-content: space-between; align-items: center; gap: 1rem;

Common mistakes

  • Using flexbox for full two-dimensional page layouts — CSS grid is usually simpler.
  • Forgetting flex-wrap: wrap, so items squeeze instead of wrapping.
  • Setting widths on items instead of flex-basis and letting them shrink unexpectedly.

Privacy

Everything you type is processed in your browser. Nothing you enter is sent to our servers or stored by us. There's no account to create and nothing to install.

Frequently asked questions

What does flex: 1 mean?

It's shorthand for flex-grow 1, flex-shrink 1 and flex-basis 0 — the items share the free space equally.

justify-content or align-items?

justify-content works along the main axis (a row's horizontal), align-items along the cross axis (a row's vertical).

Should I use gap or margins?

Use gap — it spaces items evenly without extra space at the edges.

Content last updated . See how M2Toolkit works.

Other tools people use alongside the css flexbox generator.