In this lesson, we look at multiple examples to understand the behavior of flex-grow
property in various scenarios.
Example 1: Equal Distribution
In the above example, each of the flex items p1
, p2
, and p3
has a flex-grow
value of 1, which means they will equally share any extra space.
Example 2: Unequal Distribution
In the above example, the flex item p1
, which has a flex-grow
value of 2, will take up twice as much extra space compared to p2
and p3
. The items, p2
and p3
, each with a flex-grow
value of 1, will share the remaining extra space equally.
Example 3: No Growth
In the above example, the flex item .p1
, which has a flex-grow
value of 0, will not grow and will remain fixed in size based on its content. On the other hand, the flex items .p2
and .p3
, each with a flex-grow
value of 1, will share any available extra space equally.
The flex-grow property is a tool in CSS Flexbox for controlling how flex items expand to fill available space within a flex container.