What Does the CSS "flex-shrink: 0" Property Do?

In CSS, when you set the flex-shrink property to 0, it means that the flex item will not shrink to fit the available space if there is not enough space in the flex container.

The flex-shrink property accepts a unitless number as its value. The higher the value, the more the flex item will shrink relative to other flex items in the container. If multiple flex items have a flex-shrink value greater than 0, they will shrink proportionally based on their individual flex-shrink values.

By setting flex-shrink: 0, you are essentially instructing the flex item to maintain its original size and not shrink. This can be useful in certain cases, such as when you want to prevent a flex item from reducing its size and potentially causing content to overflow or distort within the flex container.


This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.