Skip to content
induwara.lk
Premium
induwara.lkDeveloper · Browser-only

CSS Flexbox Generator

Toggle every flex-container and flex-item property, watch the live preview rearrange, and copy spec-accurate CSS you can paste straight into your project. Runs entirely in your browser — no signup, no upload, works offline.

By Induwara AshinsanaUpdated Jul 17, 2026
CSS Flexbox generatorcontainer + item controls
Main → horizontal (left → right)Cross → vertical
1
2
3

Enabled once flex-wrap is wrap or wrap-reverse.

px
Presets

Currently editing 3 items in a row container.

Sources: W3C CSS Flexbox 1 · MDN flexbox · verified 2026-07-17

How it works

The generator keeps your layout as a small structured configuration — the six container properties, a list of items, and the per-item flex values. Every time you change a control, that configuration is re-serialised to CSS by a pure module and fed into both the preview and the copy box, so what you see is exactly what you paste. Only the legal values from the W3C CSS Flexible Box Layout Module Level 1 are offered, so you cannot produce an invalid rule.

The main axis and the cross axis. Flexbox lays items along a main axis and aligns them on the perpendicular cross axis. With flex-direction: row the main axis is horizontal, so justify-content moves items left-to-right and align-items moves them top-to-bottom. Switch to column and the axes swap — the single biggest source of flexbox confusion. The axis badge above the preview always shows the current orientation (W3C Flexbox §4–5).

Minimal, correct output. The serialiser emits display: flex; always, then adds a declaration for a property only when its value differs from the CSS initial value — flex-direction: row, flex-wrap: nowrap, justify-content: flex-start, align-items: stretch, align-content: stretch, and gap: 0. That keeps the snippet short and copy-paste-correct — nothing you did not choose ends up in your stylesheet.

align-content only when it matters. Per the spec, align-content has no effect on a single-line flex container. The tool therefore emits it only when flex-wrap allows multiple lines, and shows an inline notice when you pick a value that would currently be a no-op — the behaviour MDN documents as the classic “why is align-content not working” gotcha.

Per-item flex. Each item can override flex-grow, flex-shrink, flex-basis, align-self, and order. Grow, shrink, and basis are combined into the flex shorthand and emitted together when any of the three leaves its initial 0 1 auto. Item rules are numbered by source order as .item-1, .item-2, and so on, and an item left fully default produces no rule at all.

Worked examples

Space-between navbar

Logo left, links right, vertically centred — the most-copied flex layout.

  1. flex-direction: row (default, omitted)
  2. justify-content: space-between
  3. align-items: center
  4. Items: 2, both default
  5. CSS: .container { display: flex; justify-content: space-between; align-items: center; }
  6. Why: row is the default so it is omitted; the two non-default alignments are emitted; the two items sit at the ends of the main axis.

Vertical stack with one growing panel (axis swap)

Switching to column moves the main axis to vertical — the edge case that trips people up.

  1. flex-direction: column
  2. flex-wrap: wrap
  3. align-content: center
  4. gap: 16px
  5. Item 2: flex-grow: 1
  6. CSS: .container { display: flex; flex-direction: column; flex-wrap: wrap; align-content: center; gap: 16px; } .item-2 { flex: 1 1 auto; }
  7. Why: column is non-default so it is emitted; align-content is valid because wrap allows multiple lines; item 2's grow of 1 serialises to flex: 1 1 auto while items 1 and 3 stay default and produce no rule.

align-content no-op (edge case)

Selecting align-content while flex-wrap is nowrap does nothing — the tool omits it and warns you.

  1. flex-wrap: nowrap
  2. align-content: space-between (chosen)
  3. CSS: .container { display: flex; }
  4. Why: A single-line container has no extra lines to distribute, so align-content has no effect and is left out of the output. The generator shows a notice instead of silently emitting a dead property.

Frequently asked questions

Sources & references

Property values and axis rules were last cross-checked against the W3C specification and MDN on 2026-07-17. The page is re-verified when the CSS Flexbox module advances or MDN updates its guidance.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.