How to Use the CSS Flexbox Generator: Steps and a Worked Example
Generate a flexbox container rule from direction, alignment and gap. This guide shows what to enter, a worked example, and the limits to keep in mind. The CSS Flexbox Generator tool is free, needs no account and runs in your browser.
What you need
- Direction: choose row, column, row-reverse, column-reverse
- Justify content (main axis): choose center, flex-start, flex-end, space-between, space-around, space-evenly
- Align items (cross axis): choose center, stretch, flex-start, flex-end, baseline
- Gap (px), for example 16
Step by step
- Open the CSS Flexbox Generator tool.
- Choose Direction.
- Choose Justify content (main axis).
- Choose Align items (cross axis).
- Fill in Gap (px).
- Read the result, which updates as soon as the inputs change.
Worked example
With these inputs:
- Direction: row
- Justify content (main axis): center
- Align items (cross axis): center
- Gap (px): 16
the tool returns:
.container {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 16px;
}
A second example
Changing Gap (px) 16 to 32 gives:
.container {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 32px;
}
Comparing two runs like this is a quick way to see how much each input moves the result.
How it works
Choose the direction, how items are spaced along it and how they align across it, then copy the CSS.
Things to keep in mind
Check your inputs, units and any local rules before you rely on the result.
Related tools
If this is not quite what you need, try CSS Border Radius Generator, CSS Box Shadow Generator or CSS Color Extractor.