Choose the right axis for your layout
Flexbox arranges children along a main axis, making it a useful choice for navigation, action rows, and groups of flexible cards. The direction changes which axis justify-content controls. Understanding that relationship makes the controls more useful than memorizing individual settings.
How to use this tool
- Set flex-direction to row or column. With row, the main axis is horizontal; with column, it is vertical.
- Use justify-content for the main axis and align-items for the cross axis. Turn on wrapping when a row should break onto another line.
- Apply the container CSS to the parent and any item rules to its direct children. Test the widest label and smallest supported screen.
Each button starts with a 160-pixel preferred basis and can grow or shrink. Wrapping lets the group move onto more lines when space is limited. Gap keeps the spacing predictable without adding margins to individual items.
Read the reference documentation ↗