flex
flex-grow
Defines flex growth factor.
Growth factor specifies how much of the flex container's positive free space
(if any) should be assigned to the flex item's main size
.
flex-grow
value is a ratio.
flex-grow
is applied evenly to container items equally to any other value greater than 0
will produce the same result.Flex container is 700px
main size.
There are four items in the container with 100px
in main size with flex-grow
factor of 0, 1, 2, 3
respectively.
There remains 300px
of positive free space to be distributed.
The sum of the four grow factors 0 + 1 + 2 + 3
is equal to 6
.
300px
/ 6
= 50px
50px
.flex-grow: 0; // default; prevents item from growing => 100px (original main size) flex-grow: 1; // value is a ratio, +50px => 150px flex-grow: 2; // +100px => 200px flex-grow: 3; // +150px => 250px
Positive free space
Negative free space
The main axis is the axis running in the direction the flex items are laid out in (col
or row
).
The start and end of this axis are called the main start
and main end
.
The length from the main-start edge to the main-end edge is the main size
.