Flexbox and Grid layout builder
Tune flex-direction, justify-content, align-items, flex-wrap, gap and Grid tracks or areas with a live preview of the container and its children, seven ready-made patterns, and complete copyable CSS.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Presets
Layout mode
Live preview
The container and its children render with the same parameters as the generated CSS.
Rule blocks: 2 · Child count: 3
Generated CSS
Container rule plus child rules (grid areas add per-child grid-area rules), ready to copy.
.container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
gap: 16px;
}
.container > * {
flex: 1 1 0;
}What this tool does
- Build common layouts quickly: centering, space-between, wrapping cards, equal columns, sidebar, card grid and holy grail, then fine-tune
- See the effect while you tune: container and children render live from the parameters before you copy the container and child CSS
- Generate Grid code with named areas: grid-template-areas plus per-child grid-area rules instead of hand-written nth-child
Example
Input
flex · flex-direction: row · justify-content: center · align-items: center · gap 16px · 3 children
Output
.container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
gap: 16px;
}
.container > * {
flex: 1 1 0;
}The preview and this CSS are computed from the same parameters, so any change updates both.
Frequently asked questions
Is the output complete CSS, and can I rename the class?
It emits a container rule and a child rule (`.container` and `.container > *`); grid areas additionally produce `.container > *:nth-child(n) { grid-area: … }`. The class names are samples, so rename the selectors as needed; the declarations stay valid.
How are justify-content and align-items handled in Grid mode?
Grid does not accept flex-start or flex-end, so they are translated to start and end. Every other value (center, space-between, stretch, baseline and so on) is emitted unchanged, so the generated CSS never contains keywords the browser rejects.
Does the child count change the CSS?
Yes. In Grid equal-column mode the track is repeat(childCount, 1fr), and with grid-template-areas the number of grid-area rules follows the child count. In Flex mode the child rule is fixed at flex: 1 1 0 or flex: 0 0 size, so the count only drives the number of preview blocks (also shown in the stats line).
How much track syntax is supported?
auto, min-content, max-content, px/rem/em/%/fr/ch/vw/vh lengths, minmax(), repeat() including nested forms such as repeat(auto-fill, minmax(120px, 1fr)), and fit-content(). Anything else reports invalid-track. grid-template-areas allows at most 6 lines with the same number of names per line, and names may only contain letters, digits and hyphens.
Do the preview and the generated CSS share the same data?
Yes. The preview container and children use styles from containerStyle and childStyle, while the CSS comes from buildFlexboxCss, both reading the same validated config, so the preview cannot disagree with the code. This tool generates CSS only, not the HTML structure.
Keywords:flex-directiongrid-template-columnsgrid-template-areascss-flexbox