Style flex Property
Example
Makes all flexible items have the same length, regardless of their content:
for (i = 0; i < y.length; i++) {
y[i].style.flex="1";
}
Try it »
Definition and Usage
The flex property sets or returns the length of an item relative to the other flexible items in the same container.
The flex property is a shorthand property for the flexGrow, flexShrink and flexBasis properties.
**Note:** The flex property has no effect if the element is not a flexible item.
Browser support

All major browsers except Safari support the flex property.
IE 9 and earlier versions do not support the flex property. IE 10 requires the MS prefix to support this property.
Syntax
Returns the flex property:
object
.style.flex
Sets the flex property:
object
.style.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. |
Technical Details
| Default value: | 0 1 auto |
|---|---|
| Return Value: | A string that represents the flex property of an element. |
| CSS version | CSS3 |
Related Articles
CSS Reference Manual:flex Property
HTML DOM STYLE Reference Manual:flexBasis Property
HTML DOM STYLE Reference Manual:flexDirection Property
HTML DOM STYLE Reference Manual:flexFlow Property
HTML DOM STYLE Reference Manual:flexGrow Property
HTML DOM STYLE Reference Manual:flexShrink Property
HTML DOM STYLE Reference Manual:flexWrap Property
The Style object