CSS flex properties
Examples
Let all the flexible pouch model object child elements have the same length, ignoring their internal content:
{
flex:1;
}
try it"
Browser Support
Figures in the table represent the first browser to support the property version number.
Immediately following the digital -webkit-, -ms- or -moz- after the first version to support the prefix property.
Attributes | |||||
---|---|---|---|---|---|
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
How sub-elements flex attribute is used to set or retrieve the flexible pouch model object allocated space.
flex property is a shorthand property flex-grow, flex-shrink and flex-basis property.
Note: If theelement is not flexible pouch model objects child elements, flex property does not work.
Defaults: | 0 1 auto |
---|---|
inherit: | no |
Can be animated: | Yes,see the individual attributes.Please refer to animation (Animatable) . |
version: | CSS3 |
JavaScript syntax: | object .style.flex = "1"to try |
CSS Syntax
Property Value
值 | 描述 |
---|---|
flex-grow | 一个数字,规定项目将相对于其他灵活的项目进行扩展的量。 |
flex-shrink | 一个数字,规定项目将相对于其他灵活的项目进行收缩的量。 |
flex-basis | 项目的长度。合法值:"auto"、"inherit" 或一个后跟 "%"、"px"、"em" 或任何其他长度单位的数字。 |
auto | 与 1 1 auto 相同。 |
none | 与 0 0 auto 相同。 |
initial | 设置该属性为它的默认值,即为 0 1 auto。请参阅 initial 。 |
inherit | 从父元素继承该属性。请参阅 inherit 。 |
related articles
CSS Reference Manual: Flex-Basis property
CSS Reference Manual: Flex-direction property
CSS Reference Manual: Flex-Flow Properties
CSS Reference Manual: Flex-Grow property
CSS Reference Manual: Flex-Shrink property
CSS Reference Manual: Flex-wrap property