Friday, May 10, 2019

CSS flex Property

Example

Let all the flexible items be the same length, regardless of its content:
#main div {
  -webkit-flex: 1; /* Safari 6.1+ */
  -ms-flex: 1; /* IE 10 */ 
  flex: 1;
}
Try it Yourself »

Definition and Usage

The flex property is a shorthand property for:
The flex property sets the flexible length on flexible items.
Note: If the element is not a flexible item, the flex property has no effect.
Default value:0 1 auto
Inherited:no
Animatable:yes, see individual propertiesRead about animatable
Version:CSS3
JavaScript syntax:object.style.flex="1"Try it

Browser Support

The numbers in the table specify the first browser version that fully supports the property.
Numbers followed by -webkit-, -ms- or -moz- specify the first version that worked with a prefix.
Property
flex29.0
21.0 -webkit-
11.0
10.0 -ms-
28.0
18.0 -moz-
9.0
6.1 -webkit-
17.0


CSS Syntax

flex: flex-grow flex-shrink flex-basis|auto|initial|inherit;

Property Values

ValueDescription
flex-growA number specifying how much the item will grow relative to the rest of the flexible items
flex-shrinkA number specifying how much the item will shrink relative to the rest of the flexible items
flex-basisThe length of the item. Legal values: "auto", "inherit", or a number followed by "%", "px", "em" or any other length unit
autoSame as 1 1 auto.
initialSame as 0 1 auto. Read about initial
noneSame as 0 0 auto.
inheritInherits this property from its parent element. Read about inherit

No comments:

Post a Comment