X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Style flex Property

Style Object Reference Style Object

Example

Let all the flexible items be the same length, regardles of its content:

for (i = 0; i < y.length; i++) {
    y[i].style.flex="1";
}

Try it yourself »


Definition and Usage

The flex property sets or returns the length of the item, relative to the rest of the flexibel items inside the same container.

The flex property is a shorthand for the flexGrow, flexShrink, and the flexBasis properties.

Note: If the element is not a flexible item, the flex property has no effect.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The flex property is supported in all major browsers, except for Safari.

The flex property is not supported IE 9 or earlier, in IE 10 this property is supported with the prefix MS.


Syntax

Return the flex property:

object.style.flex

Set the flex property:

object.style.flex="flex-grow flex-shrink flex-basis|auto|initial|inherit"

Property Values

Value Description
flex-grow A number specifying how much the item will grow relative to the rest of the flexible items
flex-shrink A number specifying how much the item will shrink relative to the rest of the 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.
initial Same as 0 1 auto. Read about initial
none Same as 0 0 auto.
inherit Inherits this property from its parent element. Read about inherit

Technical Details

Default Value: 0 1 auto
Return Value: A String, representing the flex property of an element
CSS Version CSS3


Related Pages

CSS reference: flex property

HTML DOM STYLE Reference: flexBasis property

HTML DOM STYLE Reference: flexDirection property

HTML DOM STYLE Reference: flexFlow property

HTML DOM STYLE Reference: flexGrow property

HTML DOM STYLE Reference: flexShrink property

HTML DOM STYLE Reference: flexWrap property


Style Object Reference Style Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook