The flex
property in
It is a shorthand property of the following:
flex-basis
flex-grow
flex-shrink
There is no effect of this property on non-flexible items.
flex: flex-grow flex-shrink flex-basis|auto|initial|inherit;
none
: It is the same as the 0 0 auto. It doesn’t have any effect on the item.
auto
: It is the same as the 1 1 auto.
flex-grow
: It is used to specify that how much the item will grow when it is compared with the other flexible items.
flex-shrink
: It is used to specify that how much the item will shrink when it is compared with the other flexible items.
flex-basis
: If we want to set the length of the flexible items then it is used. Negative values are not allowed.
initial
: sets the value to its default value.
inherit
: inherits the property from its parent value.
The basic flex
property is as follows:
In this example, we can see that we can set the flex
property of the smaller box as 1 0 auto
and the larger box as 3 0 auto
.
Therefore, we can see that the sizes of both boxes are different depending upon the different values provided in the flex property.