Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS flex property

CSS flex property

CSS Reference Manual CSS Reference Manual

Example

Make all child elements of the flexbox model object have the same length and ignore their internal content:

#main

div

{

flex:

1

;

}

Try it »


Browser support

The numbers in the table indicate the version number of the first browser that supports this property.

The number immediately following -webkit-, -ms-, or -moz- is the first version that supports the prefixed property.

property
flex 29.0
21.0 -webkit- 11.0
10.0 -ms- 28.0
18.0 -moz- 9.0
6.1 -webkit- 17.0

Definition and Usage

The flex property is used to set or retrieve how the child elements of a flexbox model object distribute space.

The flex property is a shorthand property for flex-grow, flex-shrink, and flex-basis.

**Note:** If the element is not a child of a flexbox model object, the flex property has no effect.

Default value: 0 1 auto
Inherited: No
Animatable: Yes,See the individual propertiesSee Animatable.
Version: CSS3
JavaScript syntax: object.style.flex="1" Try it

CSS Syntax

flex:

flex-grow

flex-shrink

flex-basis

|auto|initial|inherit;

Attribute values

Value Description
flex-grow A number that specifies how much the item will grow relative to the other flexible items.
flex-shrink A number that specifies how much the item will shrink relative to the other flexible items.
flex-basis The length of the item. Legal values: "auto", "inherit", or a number followed by "%", "px", "em" or any other length unit.
auto Same as 1 1 auto.
none Same as 0 0 auto.
initial Sets the property to its default value, which is 0 1 auto. See initial.
inherit Inherits this property from its parent element. See inherit.

Related Articles

CSS Reference Manual:flex-basis Property

CSS Reference Manual:flex-direction Property

CSS Reference Manual:flex-flow Property

CSS Reference Manual:flex-grow Property

CSS Reference Manual:flex-shrink Property

CSS Reference Manual:flex-wrap Property

CSS Reference Manual CSS Reference Manual