CSS flex-grow
The flex-grow
property specifies how much a flex item will grow relative to the rest of the flex items in the container when there is free space available. It is used in conjunction with the display: flex;
property to create flexible layouts.
The flex-grow
property takes a unitless value as its parameter, which determines the proportion of available space that the flex item will take up.
Here is a simple example to demonstrate how flex-grow
works:
In this example, we have three flex items within a flex container. The flex-grow
values for the items are 1, 2, and 3 respectively. This means that the second item will take up twice as much space as the first item, and the third item will take up three times as much space as the first item. If there is extra space in the container, it will be distributed according to the flex-grow
values of the items.
It is important to note that the flex-grow
property only applies when there is free space available in the flex container. If there is not enough space to accommodate all the flex items, the flex-grow
property will have no effect.