🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEcss

css Documentation

LOADING ENGINE...

CSS Flex Shrink

Control flex item sizing behavior when space is limited. Master the art of the shrink factor.

style.css
/* Rigid Item */
.sidebar {
width: 200px;
flex-shrink: 0;
}
/* Fluid Item */
.content {
flex-shrink: 1;
}
📉
flex-shrink.html
1 / 10
📉

Tutor:Welcome to Flex Shrink. This property controls how items contract when there isn't enough space in the container.


Flex Mastery Tree

Unlock nodes by understanding compression and space distribution.

Concept 1: The Shrink Factor

The flex-shrink property specifies how much a flex item will shrink relative to the rest of the flex items in the container when there isn't enough space.

System Check

What is the default value of flex-shrink?


Community Holo-Net

Share Layout Tricks

Built a responsive sidebar using flex-shrink? Share your snippet.

Enjoying this guide?

Codesyllabus is 100% free and open-source. Support our mission, pay for server infrastructure, and fuel new tutorials by buying us a coffee!

CSS Flex Shrink

Author

Pascual Vila

CSS Layout Instructor.

The flex-shrink property determines how flex items shrink if there is not enough space in the container. It sets the flex shrink factor of a flex item.

Default Behavior (Value 1)

By default, all flex items have a flex-shrink value of 1. This means that if the container is too small, all items will shrink equally to fit.

Preventing Shrinkage (Value 0)

If you set flex-shrink: 0, the item will strictly maintain its flex-basis (or width) and will not shrink, forcing other items to shrink more or causing overflow.

Proportional Shrinking

If you assign higher values, the item shrinks more aggressively. For example:

  • Item A: flex-shrink: 1
  • Item B: flex-shrink: 2

Item B will absorb twice as much "negative space" as Item A.

Best Practices

Use flex-shrink: 0 for fixed elements like avatars, icons, or navigation sidebars. Use default or higher values for fluid content areas that can adapt to smaller screens.

Flex Shrink Glossary

flex-shrink
CSS property that sets the flex shrink factor. Controls how much the item will shrink relative to the rest of the flex items.
Negative Space
The amount of overflow width that needs to be removed from the items to fit them into the container.
flex-basis
The initial main size of a flex item before the remaining space is distributed or shrinkage occurs.
flex-shrink: 0
A specific value that prevents the item from shrinking at all, regardless of the container size.