Skip to the page
css reference · flexbox

CSS flex (grow / shrink / basis)

type
property (on each flex item)
applies to
the children of a flex container
inherits
no
common values
flex: 1; flex: 0 0 240px; flex: 1 1 auto

Where it goes

On the items inside whatever has display: flex. Different items can have different values. That is the point.

Example

.layout {
  display: flex;
}
.sidebar {
  flex: 0 0 240px;
}
.content {
  flex: 1;
  min-width: 0;
}

Common mistakes

  • Setting flex: 1 on the parent instead of the items. It only means something on a child of a flex parent.
  • Expecting equal columns from flex: 1 when the items hold very different content. flex: 1 sets the starting size to 0 and shares all the room, so it does give equal columns. flex: 1 1 auto does not, because it starts from each item's own size.
  • Fighting an item that will not shrink below its content. A long word or an image sets a minimum. Add min-width: 0 to the item to let it shrink past that.

Related

Updated 24 October 2026. Practice it in the css route, or read more on MDN.