flex: 1 is three properties wearing one name. Read back from a
browser on 2026-09-02, it computes to 1 1 0%: grow 1, shrink 1,
basis 0. And flex: none computes to 0 0 auto. Almost
every confusing flex layout is one of those three numbers being something other
than what was intended.
The three, in the order they are applied. Basis is the size
the item starts at before any space is shared, and 0 means start
from nothing rather than from the content's own width.
Grow is the share of leftover space it takes.
Shrink is the share of the overflow it gives back when there is
not enough room.
The measurement, and why the numbers are not a ratio of the row
A 600px row with a 10px gap holding three items,flex: 1, flex: 2 and a fixed 200px one, laid out as
127 / 253 / 200. The fixed item takes 200 and the two gaps take
20, leaving 380 to share; grow 1 and grow 2 split that in a one to two ratio,
giving about 127 and 253.
Worked row measurement
How flex: 1 and flex: 2 split leftover space, not the container
Fixed items and gaps come out of the 600px row first, and only the remaining 380px is divided in a one-to-two ratio.
px
- 600pxRow width
- 200Fixed item
- 20Two 10px gaps
- 380Leftover to share
- 127flex: 1 item (1 share)
- 253flex: 2 item (2 shares)
flex: 2 only makes an item twice as wide as its neighbour when both have basis 0 and nothing else shares the row.
Interactive Practice Lab
Edit and run this snippet directly in your browser (zero setup)
.demo { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;}.box { flex: 1 1 80px; text-align: center; background: #0ea5e9;}Live Big-O Complexity & Binary Search Race Lab
Compare complexity curves at scale and watch Linear vs Binary Search race live.
So the growth numbers divide the leftover, not the container.flex: 2 does not make an item twice as wide as its neighbour except
in the special case where both have a basis of 0 and nothing else is in the row.
Reading the numbers as a ratio of the row is the most common misunderstanding
here, and it produces layouts that are right until content changes.
The two axes, and the property names that follow
justify-contentdistributes along the main axis, which is the
oneflex-directionnamesalign-itemsdistributes across the cross axis, andalign-selfoverrides it for one child- Switch to
flex-direction: columnand both of those swap which
visual direction they affect, without either property being edited gapspaces the children with no margins and no:last-childrule to remove the trailing one
The swap on direction change is the thing worth internalising. Nobody
remembers which of justify and align is horizontal, because the answer depends
on a third property, and the useful memory is main against cross rather than
horizontal against vertical.
Main against cross
How flex-direction drives justify-content and align-items
Think main versus cross rather than horizontal versus vertical, because switching to column swaps what both properties affect.
- flex-direction
- justify-content
- align-items and align-self
- flex-directionNames the main axis; switching row to column flips the other two
- justify-contentDistributes children along whichever axis is currently main
- align-items and align-selfAligns children across the cross axis without editing property names
Use gap to space children directly so no margins or :last-child cleanup rules are needed.
What to run in 2026
The browser's flexbox inspector is the tool, free in every browser. It
overlays the container showing the main axis direction, the free space, and the
computed basis of each item, which is exactly the three numbers this page is
about. It replaced changing a value and reloading, which cannot show you which
of grow, shrink and basis produced the width.
Inspecting flex in 2026
Browser flexbox overlay and native gap spacing
Built-in DevTools reveal the exact axis, free space and basis that edit-and-reload guesswork hides.
- 02grow, shrink and basis
- 03gap replaces margin + :last-child
- 01Main axis and free spaceDisplays direction and remaining room directly on the page
- 02Computed basis readoutShows which of the three numbers produced each item's width
- 03Native flex gapSupported everywhere in 2026; removes trailing-margin bugs when order changes
Both the flexbox inspector and gap are free with the platform and eliminate blind CSS trial and error.
gap is the second, free with the platform and supported in flex
layouts everywhere as of 2026. It replaced margins on children plus a rule to
strip the last one, which is two declarations, a selector, and a bug every time
the order changes or an item is hidden.
Where this stalls people
The stall is an item that will not shrink below its content. Shrink is on by
default, so the item should give space back, and it does not, because a flex
item's minimum size is its content size unless you say otherwise. A long word or
a wide table inside it sets a floor that the numbers cannot get under.
One shorthand, three properties
What holds up the width of a flex item
Remove any one of these three and the sentence above the figure stops being true, because the width is decided by all three in order.
- flex-basisWhere it starts. 0 means ignore the content's own width
- flex-growIts share of the leftover space, not of the container
- flex-shrinkIts share of the overflow, blocked by the content minimum
flex: 1, which is 1 1 0%
When a long word or wide table stops shrink from working, setting min-width: 0 on that flex child removes the content floor.
The fix is min-width: 0 on that item, and it is the single most
useful line in this whole area. It is unintuitive enough that it is worth
knowing as a fact rather than deriving: when a flex child overflows its
container and shrink is not helping, set its minimum width to zero. Laying the
same content out in both directions at once is
laying out in two dimensions, the
boxes being laid out are
margin, border, padding, and
where widths go wrong, and making it work at every size is
one document, every screen,
inside how a page is laid out and how it
looks.