Free Online CSS Flexbox Generator
Change the container settings, add up to 10 boxes, watch the layout update, and copy the CSS.
How to use the Flexbox Generator?
Set Container Direction
Choose row (horizontal) or column (vertical) to define the main layout axis.
Align & Justify
Use Justify Content for main axis alignment and Align Items for cross axis.
Configure Child Items
Add or remove items (1 to 10) and set Flex Grow, Shrink and Basis. The same values apply to every item.
Main Axis vs Cross Axis
In Flexbox, Main Axis follows flex-direction. Justify-content controls Main Axis while Align-items controls Cross Axis.
Key Features
- Container settings: direction, wrap, justify, align, gap
- Item settings: grow, shrink and basis
- Live preview with 1 to 10 boxes
- Copyable CSS for .container and .items
Frequently Asked Questions
When should I use Flexbox instead of CSS Grid?
Flexbox is designed for 1-dimensional layouts (arranging elements in either a single row or column), whereas CSS Grid is best suited for 2-dimensional layouts (rows and columns simultaneously).
What is the difference between flex-grow and flex-shrink?
flex-grow defines how much a flex item will expand relative to sibling items when extra space is available, while flex-shrink defines how much an item will contract when container space is restricted.