1. Direction sets the main axis
row makes the main axis horizontal. column makes it vertical. Once that changes, justify-content and align-items appear to swap roles because they always follow axis logic, not screen direction.
Preview direction, wrapping, spacing, and alignment in one place. Each control updates the live example, explains the property, and outputs clean starter code.
flex-direction, justify-content, align-items, align-content, and gap.
flex-grow, flex-shrink, flex-basis, and align-self for any item.
Use presets for common patterns or adjust each property directly. Inputs are clamped to safe ranges to avoid invalid CSS or empty-state rendering bugs.
Click any preview item to edit it individually. Item-specific values are also sanitized before generating code.
The container below updates immediately. The labels summarize which axis is acting as the main direction so you can connect the CSS to what you see.
The CSS includes only the properties represented in the tool. HTML labels use semantic class names so the snippet is easy to adapt into a real component.
Flexbox lays out direct children of a flex container across a main axis and a cross axis. The tool below explains the most common points of confusion without burying the basics in jargon.
row makes the main axis horizontal. column makes it vertical. Once that changes, justify-content and align-items appear to swap roles because they always follow axis logic, not screen direction.
When flex-wrap is nowrap, align-content has no visible effect. It matters only when items form multiple lines and there is extra space between those lines.
flex-grow controls how spare space is shared, flex-shrink controls how items compress, and flex-basis is the starting size before that negotiation begins.
Assumptions: generated basis values use pixels, gaps use whole pixels, and the preview reflects modern browser behavior. Rounding is limited to integer pixel values for readability.
Use this as a fast lookup after testing a layout in the generator.
justify-contentMoves items along the main axis. Great for nav bars, button groups, and distributed rows.
align-itemsControls cross-axis alignment for all items at once. Use it when card heights or inline content feel uneven.
align-selfOverrides the cross-axis alignment for one item without changing the rest of the group.