Flexbox Engine Visualizer
Understand the flexbox algorithm interactively. Control flex-grow, flex-shrink, flex-basis, and alignment on a live container. See how the browser distributes free space, handles overflow, and resolves wrapping.
The flexbox algorithm distributes free space proportionally among flex items based on their flex-grow values, and shrinks overflowing items proportionally by flex-shrink × flex-basis. This visualizer shows the exact pixel math in real time as you adjust each item's flex properties.
Container
Items
Live Preview
Generated CSS
.container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: stretch;
gap: 8px;
width: 600px;
height: 120px;
}
.item-a {
flex: 1 1 0px;
}
.item-b {
flex: 2 1 0px;
}
.item-c {
flex: 0 1 120px;
}
.item-d {
flex: 1 2 0px;
}container - gaps - Σ(basis) = 456pxflex-growFrequently Asked Questions
What is flex-basis?
flex-basis is the item's initial main-axis size before free space is distributed. It overrides width (in row direction) or height (in column direction).
How does flex-grow work?
Free space = container size - sum of flex-basis values. Each item receives: free space * (own flex-grow / sum of all flex-grow values). Items with flex-grow: 0 don't grow.
When does flex-shrink apply?
flex-shrink only activates when items overflow their container (negative free space). Items shrink proportional to their flex-shrink * flex-basis product.