CSS Flexbox Playground
Align, Justify and Wrap Live
See flexbox do what you say. Change direction, wrap, justify-content, align-items, align-content and gap, add up to 12 items and tune each one, then copy the CSS or Tailwind classes. 100% client-side. Zero data stored.
CSS Flexbox Playground Tool
Play with a Flex Container
Presets
Container
Item 1
Click an item in the preview to select it, then change its values here.
The dashed line is the container. In the preview each item has a number and a little padding. That padding is not in the CSS, and width and height are written only when you set them.
CSS
Tailwind CSS
The Container and Item lines are labels for reading; copy the classes after the colon onto each element. Only items that differ from the default get a line. Tailwind 3 and 4.
Common Use Cases
Navigation Bars
Put the logo on the left and the links on the right with a growing spacer, then copy the container and the one item rule.
Equal Columns
Give every item flex: 1 so a row of cards shares the width evenly and stays that way as the viewport changes.
Sidebar and Content
Fix a sidebar at 200px that never shrinks and let the content take the rest of the row.
Sticky Footers
Stack header, main and footer in a column and let main grow, so a short page still pushes the footer to the bottom.
Wrapping Card Rows
Let cards wrap onto new lines and grow to fill each row, with a basis that decides when to break.
Learning Flexbox
Change one property at a time and watch the preview and the CSS together, which is the fastest way to build intuition.
Flexbox Property Reference
Container Properties
| Property | What it does |
|---|---|
| flex-direction | Sets the main axis: row, column or either reversed |
| flex-wrap | Lets items move to a new line instead of shrinking |
| justify-content | Spreads items along the main axis |
| align-items | Aligns items on the cross axis, one line at a time |
| align-content | Spreads the lines on the cross axis; needs wrapping |
| gap | Space between items; row-gap and column-gap |
Defaults are not written: a plain container is just display: flex.
Item Properties
| Property | What it does |
|---|---|
| flex-grow | Share of the spare space an item takes |
| flex-shrink | How much an item gives up when space runs short |
| flex-basis | Starting size before growing or shrinking |
| align-self | Overrides align-items for one item |
| order | Changes visual order without changing the HTML |
The three flex values are written as the shortest flex shorthand: flex: 1 for 1 1 0%, flex: none for 0 0 auto, flex: auto for 1 1 auto.
Items will not shrink below their content
A flex item has an automatic minimum width equal to its content. A long word or a wide image can overflow even with shrink on. Set min-width: 0 on the item to let it shrink.
order is visual only
order moves items on screen but not in the page source or the tab order, so keyboard and screen reader users still get the HTML order. Keep the two close.
One dimension at a time
Flexbox lays out a row or a column. For rows and columns together, with named areas, use the Grid Generator.
Related tools
Round the corners with the Border Radius Generator and add depth with the Box Shadow Generator.
Pro Tip: URL Parameters
Open the playground with a layout already loaded. Use ?preset= with centered, navbar, columns, sidebar, footer or cards, or describe the whole layout with ?c= for the container and ?i= for the items. For example: /flexbox-playground/?preset=navbar or /flexbox-playground/?c=row,wrap,center,center,stretch,8,8,&i=0,1,auto,auto,0,,~1,1,200px,auto,0,,
c is direction, wrap, justify-content, align-items, align-content, row gap, column gap and height (empty is auto). Each item in i is grow, shrink, basis, align-self, order, width and height, with items joined by a tilde. The link in your address bar updates only after you change something, and the Copy Link button builds it from your current layout.
Frequently Asked Questions
Why We Built This Flexbox Playground
Flexbox is simple until the second property. Direction swaps the meaning of justify and align, wrap changes what align-content does, and a growing item behaves differently depending on its basis. Reading the specification does not build the intuition; changing a value and watching the boxes move does. We built a playground where every container property and every item property is one control away, and the CSS updates as you click.
The output only contains what differs from the defaults, so a plain container is just display: flex and an unchanged item gets no rule at all. The three flex values are written as the shortest valid shorthand. You can copy the CSS, copy Tailwind classes for the container and each changed item, download a stylesheet, and share a link that restores the exact layout. Everything runs in your browser and nothing you build is uploaded.
The Flexbox Playground is part of RJL.io's collection of free developer tools. For two-dimensional layouts try the Grid Generator, round the corners with the Border Radius Generator, and add depth with the Box Shadow Generator.