Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. flex-shrink

flex-shrink

Specifies the shrink factor of a flex item. Controls how much each item is reduced when the total size of items exceeds the container.

Sample Code

/* Shrink at the same rate as other items (initial value) */
.item { flex-shrink: 1;}

/* Do not shrink */
.item-fixed { flex-shrink: 0;}

/* Shrink at twice the rate of other items */
.item-shrink { flex-shrink: 2;}

Available Values

ValueDescription
<number>A number of 0 or greater. Initial value is '1' (shrinks at the same rate as others). Negative values are invalid.

Specification

ItemDetails
Initial value1
Applies toFlex items
InheritedNo
AnimationYes (interpolated as number)

Browser Compatibility

Chrome Chrome
29+
28
27
26
25
24
23
22
↑ Requires prefix '-webkit-'
21 or earlier ×
Firefox Firefox
20+
19 or earlier ×
Safari Safari
9+
8
↑ Requires prefix '-webkit-'
7 or earlier ×
Edge Edge
12+
Supported in all versions
IE IE
11
10
9 ×
8 ×
7 ×
6 ×
Opera Opera
12.1+
11 or earlier ×
iOS Safari iOS Safari
9+
8
↑ Requires prefix '-webkit-'
7 or earlier ×
Android Android Browser
4.4+
3 or earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop version
Firefox Android Firefox Android
Latest
Same support as desktop version

※ Version data based on MDN / Can I Use.

Overview

'flex-shrink' is a property applied to flex items that controls how much each item shrinks when the total size of items exceeds the container. The initial value is '1', meaning all items shrink at the same rate.

How Shrinking Works

All items flex-shrink: 1 — shrink equally A (1) B (1) C (1) Container: 350px A only flex-shrink: 0 — A does not shrink A (0) fixed B (1) C (1)

The 'flex-shrink' value works as a ratio. When all items have the initial value of 'flex-shrink: 1', the deficit is reduced equally. Setting a specific item to 'flex-shrink: 0' prevents it from shrinking.

/* Container width: 400px, total item width: 600px → deficit: 200px */

/* All items flex-shrink: 1 → shrink equally */
.item-a { width: 200px; flex-shrink: 1;}  /* approx. 133px */
.item-b { width: 200px; flex-shrink: 1;}  /* approx. 133px */
.item-c { width: 200px; flex-shrink: 1;}  /* approx. 133px */

/* item-a flex-shrink: 0 → does not shrink */
.item-a { width: 200px; flex-shrink: 0;}  /* 200px (fixed) */
.item-b { width: 200px; flex-shrink: 1;}  /* 100px */
.item-c { width: 200px; flex-shrink: 1;}  /* 100px */

Pattern: Fixed-Width Sidebar + Flexible Main Content

Wide screen Sidebar 250px Main (wide) Narrow screen — Sidebar doesn't shrink Sidebar 250px Main (shrunk)

/* Keep sidebar fixed, allow main content to shrink */
.layout {
    display: flex;
}
.sidebar {
    width: 250px;
    flex-shrink: 0;  /* sidebar stays fixed width */
}
.main {
    flex-grow: 1;
    flex-shrink: 1;  /* main can shrink */
}

The Importance of 'flex-shrink: 0'

For elements that should remain a fixed size (logos, icons, sidebars, etc.), setting 'flex-shrink: 0' is best practice. Using only 'width' may allow unintended shrinking when the container becomes narrow.

Relationship with 'min-width'

min-width: auto (default) — won't shrink below text width Very long text overflows... Overflow! min-width: 0 — can shrink below text width Very long... B Fits ✓

The initial value of 'min-width' on a flex item is 'auto', meaning it cannot shrink below the minimum size of its content (text or images). If text overflows even with 'flex-shrink: 1', adding 'min-width: 0' allows the item to shrink below its content size.

/* Fix for text overflow */
.item {
    flex-shrink: 1;
    min-width: 0;       /* allow shrinking below content size */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

Related Properties

PropertyDescription
flex-growSpecifies the grow factor. 'flex-shrink' is for reducing size; 'flex-grow' is for increasing size.
flex-basisSpecifies the base size. The 'flex-shrink' calculation applies to the deficit from the 'flex-basis' size.
flexShorthand for 'flex-grow', 'flex-shrink', and 'flex-basis'. Using 'flex' is recommended over specifying them individually.
min-widthSpecifies the minimum width. Shrinking via 'flex-shrink' will not go below this value.

If you find any errors or copyright issues, please .