CSS flexProperty
Example
Make all child elements of flexbox objects have the same length, ignoring their internal content:
Try it Yourself »
Browser Support
The numbers in the table indicate the first browser version that supports the property.
The number 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 child elements of a flexbox object allocate space.
The flex property is a shorthand property for the flex-grow, flex-shrink, and flex-basis properties.
Note:If the element is not a child element of a flexbox object, the flex property has no effect.
| Default value: | 0 1 auto |
|---|---|
| Inherited: | no |
| Animatable: | is,See the individual propertiesPlease refer to.Animatable。 |
| version: | CSS3 |
| JavaScript Syntax: | object.style.flex="1" Try it Yourself |
CSS Syntax
Property value
| Value | Description |
|---|---|
| flex-grow | A number specifying how much the item will grow relative to other flexible items. |
| flex-shrink | A number specifying how much the item will shrink relative to 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 alsoinitial。 |
| inherit | Inherited from the parent element. Seeinherit。 |
Related Articles
CSS Reference:flex-basis property
CSS Reference:flex-direction property
CSS Reference:flex-flow property
CSS Reference:flex-grow property
CSS Reference:flex-shrink property
CSS Reference:flex-wrap property
other extensions