flex: 1 vs flex: auto vs flex: 1 1 0: Why Flex Items Have Unequal Widths
flex: 1 vs flex: auto, measured: computed values, widths for three items with different content, the grow and shrink arithmetic, min-width: 0 and a flex-wrap card grid.
On this page ⌄
If three flex items have flex: 1 and still come out different widths, the cause is almost always flex: auto (or 1 1 auto) in disguise, a long unbreakable string, or width fighting flex-basis. Each was measured in Chrome 156 and the grow and shrink arithmetic was checked by hand against the browser's numbers. The Flexbox Generator lets you try the three values on live items.
What the shorthand keywords expand to
Each value was set on an element and the computed longhands (flex-grow flex-shrink flex-basis) were read:
| declaration | grow shrink basis |
|---|---|
flex: 1 | 1 1 0% |
flex: 2 | 2 1 0% |
flex: 0 | 0 1 0% |
flex: auto | 1 1 auto |
flex: none | 0 0 auto |
flex: initial (the default) | 0 1 auto |
flex: 1 1 0 | 1 1 0px |
flex: 1 200px | 1 1 200px |
A single unitless number sets the grow factor, sets shrink to 1 and sets the basis to 0%. That is the reason flex: 1 is not the same as flex: 1 1 auto: the basis is zero, not the content size.
Same three items, four declarations
Three items with different text lengths in a 600px container (display: flex, no gap), widths in px:
| declaration on each item | widths (short, medium, long) |
|---|---|
flex: 1 | 200, 200, 200 |
flex: auto | 31.4, 164.3, 404.3 |
flex: none | 7.1, 140, 379.9 |
nothing (initial, 0 1 auto) | 7.1, 140, 379.9 |
flex: 1gives equal columns because every item starts at 0 and all 600px is free space, shared by equal grow factors.flex: autostarts each item at its content width, then shares what is left. The long item stays larger. These are the "unequal widths" most people ask about.flex: noneand the initial value both keep the content size here, since the content fits and neither grows (the 600px is not filled: the three widths add to 527px).
If you want equal columns regardless of content, use flex: 1, and add min-width: 0 (below) for content that cannot wrap.
The grow arithmetic, checked
Free space is the container width minus the sum of the bases. Each item gets free * grow / sum(grow) added to its basis. Three items with grow factors 1, 2, 1:
| container | bases | free space | calculated | measured |
|---|---|---|---|---|
| 600px | 200, 200, 200 | 0 | 200, 200, 200 | 200, 200, 200 |
| 800px | 200, 200, 200 | 200 | 250, 300, 250 | 250, 300, 250 |
| 800px | 0, 0, 0 | 800 | 200, 400, 200 | 200, 400, 200 |
| 800px | 100, 100, 100 | 500 | 225, 350, 225 | 225, 350, 225 |
The first row is the common surprise: with a 200px basis in a 600px container there is no free space, so grow factors do nothing. Grow ratios only show up as 1:2:1 when the basis is 0. In the last row, 500px of free space splits as 125, 250, 125 on top of 100px each.
The shrink arithmetic
When bases exceed the container, the overflow is removed in proportion to flex-shrink * basis, not just flex-shrink:
| container | bases and shrink | overflow | calculated | measured |
|---|---|---|---|---|
| 500px | 200, 200, 200 (shrink 1) | 100 | 166.67 each | 166.67 each |
| 450px | 300, 200, 100 (shrink 1) | 150 | 225, 150, 75 | 225, 150, 75 |
| 400px | 300 (shrink 1), 300 (shrink 2) | 200 | 233.33, 166.67 | 233.33, 166.67 |
In the second row the weights are 300, 200 and 100 out of 600, so the items lose 75, 50 and 25px. In the third row the weights are 300 and 600, so the items lose 66.67 and 133.33px. A larger item shrinks by more pixels at the same flex-shrink.
flex-basis against width
flex-basis wins over width for the main axis unless it is auto. In an 800px container with an item that has width: 100px:
| extra declaration | item width |
|---|---|
flex-basis: auto | 100 |
flex-basis: 200px | 200 |
flex: 1 (basis 0%) | 800 |
flex-basis: content | 8 |
The last line shows that flex-basis: content does not behave "like auto". With content, the width: 100px was ignored and the item was sized from its content (8px for one letter). Use auto if you want width honoured.
Text that refuses to shrink: min-width: 0
A flex item's automatic minimum size is its content size, so a long unbreakable string stops the item from shrinking. Two items with flex: 1 in a 500px container, one holding an 80-character string with no spaces:
| fix | widths |
|---|---|
| none | 596, 32 |
min-width: 0 | 250, 250 |
min-width: 0 and overflow-wrap: anywhere | 250, 250 |
overflow: hidden | 250, 250 |
Without the fix, the first item was 596px in a 500px container and the second item was squeezed to 32px. min-width: 0 (or overflow: hidden, which resets the automatic minimum) restores the equal split; add overflow-wrap: anywhere if you want the string to wrap and not overflow its box visibly. The same thing happens with <pre>, long URLs and wide images.
A wrapping card grid with flex-wrap
.cards { display: flex; flex-wrap: wrap; gap: 16px; }
.cards > * { flex: 1 1 250px; }
Five cards, rows of widths in px:
| container | rows |
|---|---|
| 1000px | 322.7 + 322.7 + 322.7 / 492 + 492 |
| 700px | 342 + 342 / 342 + 342 / 700 |
| 400px | 400 / 400 / 400 / 400 / 400 |
Flexbox sizes each row independently, so a short last row stretches to fill the line (two cards at 492px under three at 322.7px, and a single card at 700px). That is the difference from grid, where repeat(auto-fill, minmax(250px, 1fr)) keeps columns aligned. To stop the last row from stretching, cap the card with max-width: with max-width: 300px the 1000px result was 300 + 300 + 300 / 300 + 300. Or use flex: 0 1 250px, which gave 250 each in rows of 3 and 2 with leftover space at the end. If you want aligned columns, use grid.
Quick rules
- Equal columns:
flex: 1(plusmin-width: 0if content can be long). - Content-sized items that share leftover space:
flex: auto. - Fixed width that never changes:
flex: noneorflex: 0 0 280px. - Check for free space before blaming
flex-grow: when the bases already fill the container, grow does nothing.
Tested
2026-11-02, Chrome 156.0.8078.48 via playwright-core on Windows 11; widths from getBoundingClientRect, longhands from getComputedStyle. Each calculated value in the tables was worked out by hand and matched the browser. Not tested: Firefox, Safari. The old post's flex: 0 = 0 1 0% and its shrink example were correct; its flex-basis: content description was not.
Related tools
Flexbox Generator
Visual CSS Flexbox playground. Live preview + copyable CSS. Control direction, wrap, justify, align, gap. Example child layouts.
WebP to JPG Converter
Convert WebP to JPG, PNG or WebP in your browser. Batch files, set quality, pick a background for transparency. Nothing is uploaded.
Image Compressor
Compress JPEG, PNG, and WebP images in your browser. Adjustable quality, batch mode. Files never leave your device.
Color Picker
Pick colors, convert hex/RGB/HSL/OKLCH, and check WCAG contrast.
Written by Mian Ali Khalid. More guides in Frontend & Design.