Flex shrink
flex-shrink property. It controls how much a flex item shrinks when there isn’t enough space in the container. | CSS Shortcut class | Applied style |
|---|---|
| |
| |
Examples
Shrink
flex-shrink
flex-shrink class reduces its size when space is limited, while the other two items keep their original size. 1
2
3
<div class="d-flex">
<p class="flex-none" style="width: 28rem">1</p>
<p class="flex-shrink" style="width: 28rem">2</p>
<p class="flex-none" style="width: 28rem">3</p>
</div> No shrink
flex-shrink-0
flex-shrink-0 class maintains its size when space is limited, while the other two items shrink to fit the container. 1
2
3
<div class="d-flex">
<p class="flex-none" style="width: 28rem">1</p>
<p class="flex-shrink-0" style="width: 28rem">2</p>
<p class="flex-none" style="width: 28rem">3</p>
</div> xs:> 480pxsm:> 640pxmd:> 768pxlg:> 1024pxxl:> 1280px
<div class="xs:flex-shrink ...">
...
</div>