HTML CSS examples for CSS Property:flex-grow
The flex-grow CSS property sets how the flex item will grow relative to the other items inside the flex container.
The following table summarizes the flex-grow Property.
Item | Value |
---|---|
Default value: | 0 |
Applies to: | Flex items |
Inherited: | No |
Animatable: | Yes. |
The syntax of the property is as follows:
flex-grow: number | initial | inherit
The following table describes the values of this property.
Value | Description |
---|---|
number | flex grow factor. The default value is 0. Negative numbers are invalid. |
initial | Sets this property to its default value. |
inherit | take the value of its parent element flex-grow property. |
The example below shows the flex-grow property.
<!DOCTYPE html> <html lang="en"> <head> <title>Example of CSS3 flex-grow Property</title> <style type="text/css"> .flex-container {<!--from www .jav a 2 s .c om--> width: 300px; height: 200px; font-size: 32px; border: 1px solid black; display: -webkit-flex; /* Safari */ display: flex; /* Standard syntax */ } .item1 { width: 50px; background: #e84d51; -webkit-flex-grow: 1; /* Safari */ flex-grow: 1; } .item2 { width: 50px; background: #7ed636; -webkit-flex-grow: 2; /* Safari */ flex-grow: 2; } .item3 { width: 50px; background: #2f97ff; -webkit-flex-grow: 3; /* Safari */ flex-grow: 3; } </style> </head> <body> <div class="flex-container"> <div class="item1"> 1 </div> <div class="item2"> 2 </div> <div class="item3"> 3 </div> </div> </body> </html>