flex-basis property

Image Tutorials

Definition and Usage

The CSS flex-basis property specifies the flex basis which is the initial main size of a flex item.

  • Initialauto
  • Applies toflex items, including in-flow pseudo-elements
  • Inheritedno
  • Percentagesrefer to the flex container’s inner main size
  • Mediavisual
  • Computed Valueas specified, with lengths made absolute
  • Animatableyes, as a lengthpercentage or calc(); when both values are lengths, they are interpolated as lengths; when both values are percentages, they are interpolated as percentages; otherwise, both values are converted into a calc() function that is the sum of a length and a percentage (each possibly zero), and these calc() functions have each half interpolated as real numbers.
  • Canonical orderthe length or percentage before the keyword, if both are present

Syntax

Formal syntax: <'width'>
flex-basis: value
flex-basis: inherit

Values

percentage
Computed value returns a percentage of the parent flex container main size property. Negative values are invalid.
absolute length
Defined as a number followed by a absolute unit such as px, mm or pt. Negative values are invalid.
initial
Refers to the default value of the property.
auto
The computed value of flex-basis equals the computed value of the main size of the flex item.

Note: Writing Modes Level 3 specification will introduce the following new keywords: min-content, max-content, fill-available and fit-content.

Note: flex-basis determines the size of the content-box unless specified otherwise using box-sizing.


Examples

1 element {
2   flex-basis: 18em;
3 }

Compatibility

Desktop browsers

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support 18.0 (18.0) (behind a pref)
22.0 (22.0)
21.0-webkit Not supported 12.10 Not supported

Mobile browsers

Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support NA NA Not supported 12.10 Not supported
Rate article