Skip to main content

InstrumentsFlexbox Playground

Flexbox Playground

Adjust flex direction, wrapping, alignment and gap, with a live preview and copy-ready CSS.

All tools

Flexbox Playground

From 1 to 12 boxes in the preview and the sample markup.

1
2
3
4
5

The preview uses the current browser's flexbox layout, so spacing and wrapping can differ slightly between browsers.

Flex CSS
.flex {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: stretch;
  gap: 8px;
}
Sample markup
<div class="flex">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
</div>

FAQ

Why does the preview look different in another browser?

The preview uses the flexbox layout of the browser you are using now. Spacing and wrapping can differ slightly between browsers and versions, so check the result in the browsers your users run.

What does wrap-reverse do?

It wraps items onto new lines like wrap does, but it stacks those lines in the opposite cross direction. In a row, the second line appears above the first.

Does the gap apply between items in both directions?

Yes. The gap is written in px and sits between items along both the main and cross axes. It does not add space at the outer edges of the container.

  1. 01Advanced Flexbox Architecture: Layout AlgorithmsTutorial
  2. 02CSS Grid vs Flexbox Architecture PatternsTutorial

Personalize your path

Choose your experience level once.

Next Step

Build fundamentals after each tool run so you can apply concepts with confidence.

Get new tool alerts

Receive updates when new tools are published.

RSS feed