Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Flexbox

The flex-shrink property

Reference for the CSS flex-shrink property: how flex items give up space when they do not fit, how the scaled shrink factor works, and the min-width trap.

The flex-shrink property sets the shrink factor of a flex item. When the items' bases add up to more than the container's main size, the overflow is taken back from the items in proportion to their shrink factors, scaled by each item's flex-basis. A larger item gives up more pixels than a smaller one with the same factor.

The default is 1, so by default every item can shrink. That is why a row of flex items usually squeezes together instead of overflowing.

CSS
.logo { flex-shrink: 0; }     /* never gets squeezed */
.title { flex-shrink: 1; }    /* gives way first */

Try it

Who gives way?
The min-width: 0 fix

Syntax

CSS
flex-shrink: <number>;

flex-shrink: 1;
flex-shrink: 0;
  • Initial value: 1
  • Applies to: flex items
  • Inherited: no
  • Animatable: yes, as a number
  • Computed value: as specified

Values

Value Description
1 The item shrinks when the line overflows (default).
0 The item keeps its flex basis and may overflow the container instead of shrinking.
<number> A non-negative number. Larger values shrink faster. The share is factor ร— basis divided by the sum of that product for all items. Negative values are invalid.

Usage notes

  • Scaled by size. Shrink is weighted by the basis, so with equal factors a 300px item loses twice as much as a 150px one. That keeps proportions looking natural.
  • The automatic minimum size. A flex item will not shrink below its content (min-width: auto) by default. Long words, images and <pre> blocks therefore refuse to shrink. Set min-width: 0 on the item (or overflow other than visible) to allow it.
  • Shrinking only happens on overflow. If the items fit, flex-shrink has no effect.
  • Protect fixed pieces. Icons, avatars and buttons often need flex-shrink: 0, or flex: none, so they do not get squashed when a neighbouring text is long.
  • Wrapping disables most shrinking. With flex-wrap: wrap, items move to a new line before they need to shrink, so the factor matters only for a single item that is wider than a whole line.
  • Columns. In a column container, shrinking acts on height and only if the container has a limited height.

Browser support

Supported in every browser.