Flexbox Generator
Lets you configure a flex container with direction, wrap, justify-content, align-items, align-content and gap, shows a live preview of the items, and outputs the CSS.
Use the tool
Why this tool exists
Flexbox properties are easy to mix up. Is it justify-content or align-items that centres vertically, and what flips when you change the direction to column? Even experienced developers pick a value, reload and check.
Here you change a value and see the effect straight away on a set of sample boxes that vary in size. Choose how many items to show, the direction, wrap behaviour, main-axis and cross-axis alignment, and the gap in pixels. The output is a short block of container CSS, leaving out align-content when it is set to normal. Use it to learn or to confirm a layout before you write it into your code. It all runs in your browser.
How to use it
- Choose the flex-direction and wrap behaviour.
- Set justify-content, align-items and align-content.
- Set the gap and the number of preview items.
- Copy the CSS block from the output.
Frequently asked questions
Which property aligns along which axis?
justify-content works along the main axis, which is horizontal for row and vertical for column. align-items works across it. When you switch the direction, the two swap.
When does align-content matter?
Only when items wrap onto several lines. It spreads those lines inside the container. With a single line it has no effect, which is why the tool omits it when set to normal.
Why do my items not fill the height?
Items stretch only when align-items is stretch and the container has extra height. In the preview the container fills the screen height so you can see it.
Is this the container only?
Yes. It produces CSS for the flex container. Properties on individual items, such as flex-grow, flex-basis or align-self, are not included.