Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Flexbox

The flex-grow property

Reference for the CSS flex-grow property: how a flex item takes a share of the leftover space, how ratios work, why fractions behave differently, with examples.

The flex-grow property sets the growth factor of a flex item: how large a share of the container's leftover space it receives. After the browser lays out every item at its flex-basis, any space still free along the main axis is divided among the items in proportion to their growth factors.

With the default of 0 an item never grows beyond its basis.

CSS
.sidebar { flex-grow: 0; }
.content { flex-grow: 1; }   /* takes everything the sidebar leaves */

Try it

Growth factors as ratios
Growth factors below 1

Syntax

CSS
flex-grow: <number>;

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

Values

Value Description
0 The item does not grow.
<number> A non-negative number. The item gets number รท sum of all growth factors of the free space. Negative values are invalid.

Usage notes

  • It shares free space, not total width. The final width is flex-basis plus the item's share. Two items with flex-grow: 1 but different bases end up with different widths. To get equal widths, set the basis to 0 too (that is what flex: 1 does).
  • Fractions below 1. If all the growth factors add up to less than 1, the items share only that fraction of the free space. The rest stays empty. Three items at 0.2 use 60% of the leftover space.
  • There must be free space. If the items already fill the line, growing does nothing. In a column container without a set height there is no free space.
  • Limits still apply. max-width (or max-height) caps an item, and the space it could not take is passed to the other growing items.
  • Margins can win. An auto margin on the main axis absorbs free space before growth happens, so the item will not grow.
  • Prefer flex. Writing flex-grow: 1 leaves the basis at auto, which is not the same as flex: 1.

Browser support

Supported in every browser.