Xerobit
Frontend & Design

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.

MA Mian Ali Khalid Updated Nov 2, 2026 8 min read
Free tool
Flexbox Generator
Visual CSS Flexbox playground. Live preview + copyable CSS. Control direction, wrap, justify, align, gap. Example child layouts.
Open tool →
On this page ⌄
  1. What the shorthand keywords expand to
  2. Same three items, four declarations
  3. The grow arithmetic, checked
  4. The shrink arithmetic
  5. flex-basis against width
  6. Text that refuses to shrink: min-width: 0
  7. A wrapping card grid with flex-wrap
  8. Quick rules
  9. Tested

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:

declarationgrow shrink basis
flex: 11 1 0%
flex: 22 1 0%
flex: 00 1 0%
flex: auto1 1 auto
flex: none0 0 auto
flex: initial (the default)0 1 auto
flex: 1 1 01 1 0px
flex: 1 200px1 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 itemwidths (short, medium, long)
flex: 1200, 200, 200
flex: auto31.4, 164.3, 404.3
flex: none7.1, 140, 379.9
nothing (initial, 0 1 auto)7.1, 140, 379.9
  • flex: 1 gives equal columns because every item starts at 0 and all 600px is free space, shared by equal grow factors.
  • flex: auto starts 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: none and 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:

containerbasesfree spacecalculatedmeasured
600px200, 200, 2000200, 200, 200200, 200, 200
800px200, 200, 200200250, 300, 250250, 300, 250
800px0, 0, 0800200, 400, 200200, 400, 200
800px100, 100, 100500225, 350, 225225, 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:

containerbases and shrinkoverflowcalculatedmeasured
500px200, 200, 200 (shrink 1)100166.67 each166.67 each
450px300, 200, 100 (shrink 1)150225, 150, 75225, 150, 75
400px300 (shrink 1), 300 (shrink 2)200233.33, 166.67233.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 declarationitem width
flex-basis: auto100
flex-basis: 200px200
flex: 1 (basis 0%)800
flex-basis: content8

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:

fixwidths
none596, 32
min-width: 0250, 250
min-width: 0 and overflow-wrap: anywhere250, 250
overflow: hidden250, 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:

containerrows
1000px322.7 + 322.7 + 322.7 / 492 + 492
700px342 + 342 / 342 + 342 / 700
400px400 / 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 (plus min-width: 0 if content can be long).
  • Content-sized items that share leftover space: flex: auto.
  • Fixed width that never changes: flex: none or flex: 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

Written by Mian Ali Khalid. More guides in Frontend & Design.