What Is CSS Flexbox?
Flexbox is a one-dimensional CSS layout system for arranging elements in a row or column. It is especially useful for navigation bars, centered content, button groups, card rows, sidebars and interface components where alignment and space distribution must adapt to available room.
Explore the Complete Flexbox Workflow
๐ฏ Visual alignment
Understand how direction, justification and alignment work together without repeatedly editing CSS.
โฉ Responsive wrapping
Test line wrapping, independent gaps and align-content behavior inside a realistic bounded container.
๐งฉ Item behavior
Control grow, shrink and basis globally, then select one item to change order, alignment or sizing.
โก Useful presets
Start with common patterns for centered content, navigation, wrapping cards, sidebars and bottom alignment.
๐ Clean output
Copy container CSS, per-item overrides or matching semantic HTML without styling the demo visuals.
๐ Browser based
Your configuration stays on the device; the generator does not upload layout or code content.
Main Axis vs Cross Axis
The direction in which flex items flow. With row it is horizontal; with column it is vertical. justify-content distributes space on this axis.
The axis perpendicular to the main axis. align-items positions items across it, while align-content distributes multiple wrapped lines.
Choosing grow, shrink and basis
- flex-basis defines the preferred initial size before remaining space is distributed.
- flex-grow controls how an item claims positive free space relative to its siblings.
- flex-shrink controls how an item contracts when the container is too small.
- The shorthand
flex: grow shrink basisis useful once the three values are intentional.
Frequently Asked Questions
When should I use Flexbox instead of CSS Grid?
Use Flexbox when the layout primarily follows one row or one column. Use Grid when rows and columns must coordinate as a two-dimensional system. They work well together.
Why does align-content appear to do nothing?
It only affects multiple flex lines. Enable wrapping and ensure there is extra cross-axis space in the container.
What is the difference between width and flex-basis?
Flex-basis is the preferred size on the main axis before grow and shrink are calculated. Width always describes the horizontal dimension, so the two differ when direction is column.
Can individual items use different alignment?
Yes. Select an item in the preview and change align-self. It overrides the container's align-items value for that item.