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-basis

flex-basis

Specifies the base size of a flex item — the size used as the starting point before any growing or shrinking with 'flex-grow' or 'flex-shrink'.

Sample Code

/* Auto size based on content (initial value) */
.item { flex-basis: auto;}

/* Fixed width */
.item-fixed { flex-basis: 200px;}

/* Specified as percentage */
.item-percent { flex-basis: 33.333%;}

/* Base size of 0 (for equal distribution with flex-grow) */
.item-zero { flex-basis: 0;}

Available Values

ValueDescription
autoUses the item's 'width' (or 'height') value. If not set, the size is based on content. This is the initial value.
<length>Specified using length values such as px, em, rem, etc.
<percentage>Specified as a percentage of the container's main axis size.
0Sets the base size to 0. Used when distributing free space equally with 'flex-grow'.
contentSizes the item based on its content.

Specification

ItemDetails
Initial valueauto
Applies toFlex items
InheritedNo
AnimationYes (interpolated as length/percentage; not animatable to/from 'auto')

Browser Compatibility

Chrome Chrome
29+
28
27
26
25
24
23
22
↑ Requires prefix '-webkit-'
21 or earlier ×
Firefox Firefox
22+
21 or earlier ×
Safari Safari
9+
8
7
↑ Requires prefix '-webkit-'
6 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
7
↑ Requires prefix '-webkit-'
6 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-basis' is a property applied to flex items that specifies the base size before any growing or shrinking with 'flex-grow' or 'flex-shrink'. When 'flex-direction: row', it corresponds to width; when 'column', it corresponds to height.

Difference Between 'flex-basis' and 'width'

flex-basis: auto — Content-based size Long text Short Medium flex-basis: 200px — Fixed base size A (200px) B (200px) C (200px) flex-basis: 0 + flex-grow: 1 — Perfectly equal width

A (equal) B (equal) C (equal)

Both 'flex-basis' and 'width' (or 'height') can be set on a flex item, but 'flex-basis' takes precedence (except when 'auto').

SettingResult
flex-basis: auto; width: 200px;Uses the width value of 200px.
flex-basis: 300px; width: 200px;Uses flex-basis value of 300px.
flex-basis: 0; width: 200px;Uses flex-basis value of 0.

For sizing flex items, it is better to use 'flex-basis' (or the shorthand 'flex') rather than 'width'.

Pattern 1: Equal-Width Items

flex-basis: auto — width varies by content Item with long text Short Medium text flex-basis: 0 + flex-grow: 1 — Perfectly equal Long text... Short Medium...

/* Distribute space equally with flex-basis: 0 */
.container { display: flex;}
.item {
    flex-grow: 1;
    flex-basis: 0;
    /* Or write as: flex: 1; */
}

With 'flex-basis: auto', item sizes vary based on their content. Setting 'flex-basis: 0' makes all items equal width regardless of content.

Pattern 2: Flexible Items with a Minimum Width

Wide screen — stretches beyond 300px Card (stretched) Card (stretched) Card (stretched) Narrow screen — wraps to maintain min. 300px Card (basis: 300px → wraps to 1 per row)

/* Ensure at least 300px, stretch if space available */
.card {
    flex: 1 1 300px;  /* grow:1  shrink:1  basis:300px */
}

Related Properties

PropertyDescription
flex-growSpecifies the grow factor. Controls how much the item grows beyond the 'flex-basis' size.
flex-shrinkSpecifies the shrink factor. Controls how much the item shrinks from the 'flex-basis' size.
flexShorthand for 'flex-grow', 'flex-shrink', and 'flex-basis'. Using 'flex' is recommended over specifying them individually.

If you find any errors or copyright issues, please .