CSS Flexbox Generator

Learn and build flexbox layouts: change each property and see the boxes move instantly.

FreeNo sign-upPrivate — runs in your browser
CSS

How to use the Flexbox Generator

  1. Set the directionChoose row or column, and whether items wrap onto new lines.
  2. Align the itemsUse justify-content for the main direction and align-items for the cross direction, and watch the boxes move.
  3. Copy the CSSOnly properties that differ from the defaults are included, so the code stays short.

Example

Center anything: display: flex; justify-content: center; align-items: center;

Navigation bar: justify-content: space-between; align-items: center; gap: 12px; puts the logo left and links right.

Frequently asked questions

What is the difference between justify-content and align-items?

justify-content positions items along the main direction (left to right in a row), and align-items positions them across it (top to bottom in a row). In a column they swap.

When does align-content do anything?

Only when items wrap onto more than one line. It controls the spacing between those lines.

What does flex: 1 do?

It lets each item grow to share the leftover space equally, so the items fill the whole row.

Popular posts from this blog

Character Counter

Speech to Text Online

Keyboard Tester