The flex-shrink
property specifies the flex shrink factor, which determines how much the flex item will shrink relative to the rest of the flex items in the flex container when negative free space is distributed.
This property deals with situations where the browser calculates the flex-basis values of the flex items, and finds that they are too large to fit into the flex container. As long as flex-shrink has a positive value the items will shrink in order that they do not overflow the container.
The flex-grow
property deals with distributing available positive free space proportional to each item's flex grow factor, with the value of the flex-grow
property as the only consideration. The flex-shrink
property manages removing negative free space to make boxes fit into their container without overflowing. Removing space is a bit more complicated than adding space. The flex shrink factor is multiplied by the flex base size; this distributes negative space in proportion to how much the item can shrink. This prevents smaller items from shrinking to 0px
before a larger item is noticeably reduced.
Generally, flex-shrink
is used alongside the flex-grow
and flex-basis
properties. Within the flex
shorthand, the shrink factor is always the second <number>
. If the shorthand only includes one number value, that value is assumed to be the flex-grow
value.