Free Online CSS Flexbox Generator with a Live Preview
Set direction, wrap, justify-content, align-items, align-content and both gaps on a real flex container, then click any box in the preview to give that single item its own grow, shrink, basis, align-self and order. The rules come out ready to paste, and the item rule appears only when it differs.
Click a box to select it. The item controls below then apply to that box only. Selected: Item 1
align-content has no effect while flex-wrap is nowrap, because there is only one line to space out.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
How to Build a Flexbox Layout
A few steps, and nothing is uploaded.
What to Know About Flexbox
Including the reason align-content so often looks broken.
flex-wrap: nowrap there is only one line and the property has nothing to move. This is the single most common reason flexbox looks like it is ignoring you. Set flex-wrap: wrap and make sure the boxes really do run onto a second line, then align-content starts working. The page shows a warning whenever you set it while wrap is off.
flex shorthand sets three things, and flex: 1 means 1 1 0%, which resets the basis to zero. That is why flex: 1 on items of different content widths makes them equal, while flex-grow: 1 on its own keeps the content width and only shares out the leftover space. This page writes the long-hand properties so you can see which of the three you actually changed.
flex-shrink: 0 on that one item rather than a width on the container. Set the shrink value to 0 here and watch the box hold its size.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
About the CSS Flexbox Generator
Flexbox is a one dimensional layout model: you choose a main axis, and everything else follows from that. Most of the confusion comes from the fact that the properties change meaning when you change the direction, so justify-content is horizontal in a row and vertical in a column, while align-items is the other way round. Seeing it move is worth more than reading the definitions again.
This page puts a real flex container next to the controls. Every change is applied to the container element itself, so the boxes wrap when they genuinely run out of room rather than when a simulation decides they should. The number of boxes is adjustable from three to eight for the same reason, because wrapping behaviour is invisible until there are enough items to wrap.
The hard part was the item side. Most generators only do the container, which leaves out the half of flexbox that people actually get stuck on. Here you click a box to select it, the item controls load that box, and the output grows a small rule for it. Items left on their defaults produce no rule at all, so the output stays as short as a hand written one.
Frequently Asked Questions
Wrapping, basis, shrinking and the gap property.
flex-wrap: wrap and make sure there are enough items, or enough width pressure, for a second line to exist. If there is one line, use align-items instead, which aligns items within that line.flex-basis: 0 tells the browser to ignore the content size and share the space purely by flex-grow, which is how equal columns are made. Setting it to auto means the content size is the starting point.flex-shrink: 0 on the item that must keep its size, which is usually an icon, an avatar or a fixed control. Note that a very long unbroken word also needs min-width: 0 on the flex item before it will wrap properly.