flex-basis in CSS – How to Set Flex Item's Initial Length
flex-basis sets the initial length of a flexible item.
Here’s an example:
We used the flex-basis
property to set flex-item3
’s initial length to 100px
.
Note the following:
auto
isflex-basis
’ default value.- A
flex-basis
’ value (other thanauto
) has higher specificity thanwidth
(orheight
). Therefore, suppose you define both for a flexible item. In that case, browsers will useflex-basis
. - The
flex-basis
property sets the content box’s initial width. But you can use the box-sizing property to make it set the border box’s width instead.