CSS flex-shrink Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Flexbox

What You’ll Learn

The flex-shrink property controls how much a flex item shrinks when the flex container runs out of space. It is essential for responsive layouts that must adapt on smaller screens without breaking.

01

Shrink factor

Unitless number.

02

Default 1

Items shrink.

03

Proportional

Ratios, not %.

04

Flex items

On children.

05

Main axis

Overflow space.

06

flex-shrink: 0

Lock item size.

Introduction

The flex-shrink property in CSS is part of the Flexible Box Layout Module (Flexbox). It specifies the shrink factor of a flex item, which determines how much the item will shrink relative to the rest of the flex items in the flex container when there is not enough space.

Definition and Usage

Apply flex-shrink on flex items inside a container with display: flex. Use higher values when an item should give up more space under pressure — for example, a flexible content area with flex-shrink: 2 and a logo with flex-shrink: 0 so the logo never gets squashed.

💡
Beginner Tip

Think of flex-shrink as a share of overflow. If one item has flex-shrink: 2 and another has flex-shrink: 1, the first item loses twice as much width when the container is too narrow.

📝 Syntax

The syntax for the flex-shrink property is straightforward. It is applied to flex items within a flex container:

syntax.css
element {
  flex-shrink: number;
}

Here, number is a non-negative value that represents the shrink factor of the flex item.

Basic Example

flex-shrink-basic.css
.logo {
  flex-shrink: 0; /* never shrink */
}
flex-shrink: 0; flex-shrink: 1; flex-shrink: 2;

Default Value

The default value of the flex-shrink property is 1, which means flex items will shrink proportionally when the flex container has insufficient space.

Syntax Rules

  • Apply on flex items, not on the flex container.
  • Accepts non-negative numbers (0, 1, 2, etc.).
  • A value of 0 means the item will not shrink below its flex-basis (unless min-width forces otherwise).
  • Values are proportional ratios, not percentages or pixel sizes.
  • The property is not inherited.
  • Works along the main axis only (row or column depending on flex-direction).

⚡ Quick Reference

QuestionAnswer
Initial value1
Applies toFlex items
InheritedNo
Value typeUnitless number (shrink factor)
Common patternflex-shrink: 0 on logos, icons, and sidebars

💎 Property Values

ValueDescription
numberA non-negative integer that represents the shrink factor of the flex item. A value of 0 means the item will not shrink, while a higher value indicates a greater tendency to shrink relative to siblings.

How shrink factors divide overflow

If three items have shrink values of 1, 2, and 1, and the container needs to remove 200px of overflow, items 1 and 3 each give up 50px while item 2 gives up 100px — a 1:2:1 ratio. An item with flex-shrink: 0 is excluded from shrinking entirely.

👀 Live Preview

A 280px container with three 150px-basis items. Item 2 has flex-shrink: 2, so it shrinks twice as much as items 1 and 3:

Item 1 Item 2 Item 3

Examples Gallery

In this example, we’ll demonstrate how the flex-shrink property affects flex items when the flex container is too small to fit all items — plus fixed sidebars, toolbars, and card rows.

📉 Proportional Shrinking

Start with the reference example — different shrink factors when the container is too narrow.

Example 1 — Proportional Shrink Factors

Item 2 shrinks twice as much as items 1 and 3 when the 300px container cannot fit every item at full width.

flex-shrink-proportional.html
<style>
  .container {
    display: flex;
    width: 300px;
    background: lightgrey;
  }
  .item {
    flex: 1;
    padding: 10px;
    background: cornflowerblue;
    color: white;
    text-align: center;
  }
  .item:nth-child(2) {
    flex-shrink: 2;
  }
</style>

<div class="container">
  <div class="item">Item 1</div>
  <div class="item">Item 2</div>
  <div class="item">Item 3</div>
</div>
Try It Yourself

How It Works

When the container is too narrow, overflow is removed in a 1:2:1 ratio. Item 2 gives up twice as much space as items 1 and 3.

Example 2 — Prevent Shrinking with flex-shrink: 0

Keep a sidebar or logo at its intended size while other items absorb the overflow.

flex-shrink-zero.css
.sidebar {
  flex-shrink: 0;
  width: 180px;
}
.main {
  flex-shrink: 1;
}
Try It Yourself

How It Works

The sidebar keeps its 180px width. Only the main content area shrinks when horizontal space runs out.

🛠 Layout Patterns

Use flex-shrink in real UI patterns like toolbars and card rows.

Example 3 — Toolbar with Fixed Buttons

Let a title truncate while action buttons keep their natural width.

flex-shrink-toolbar.css
.toolbar-title {
  flex-shrink: 1;
  min-width: 0;
}
.toolbar-btn {
  flex-shrink: 0;
}
Try It Yourself

How It Works

Buttons stay readable at their natural size. The title shrinks and ellipsizes because it has flex-shrink: 1 and min-width: 0.

Example 4 — Card Row with One Flexible Item

In a row of cards, let one card absorb overflow while others keep a minimum width.

flex-shrink-cards.css
.card {
  flex: 1 1 120px;
}
.card--wide {
  flex: 2 2 160px;
}
Try It Yourself

How It Works

The middle card uses a higher shrink factor (2) in the flex shorthand, so it compresses more than the side cards when the row is squeezed.

♿ Accessibility

  • Do not shrink interactive targets too small — buttons and links need enough tap area on mobile.
  • Pair shrinking with text overflow — use text-overflow: ellipsis so truncated labels remain understandable.
  • Test at narrow viewports — ensure critical content is still reachable after items shrink.
  • Use semantic structure — shrinking is visual; keep logical DOM order for screen readers.
  • Set min-width on inputs so form fields do not become unusably narrow.

🧠 How flex-shrink Works

1

Container is too small

After flex-basis and content sizes are calculated, the items overflow along the main axis.

Negative free space
2

Shrink factors are summed

Only items with flex-shrink greater than 0 participate in removing overflow space.

Ratios
3

Space is removed proportionally

Each item loses a share proportional to its shrink factor relative to the total.

Distribution
=

Flexible responsive layout

Items compress gracefully on small screens without horizontal scroll or broken layouts.

🖥 Browser Compatibility

The flex-shrink property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is widely used and considered stable for production environments.

Baseline · Universal support

flex-shrink everywhere

All shrink factor values work consistently in every modern browser as part of standard Flexbox.

99% Universal support
Google Chrome 29+ · Desktop & Mobile
Full support
Mozilla Firefox 28+ · Desktop & Mobile
Full support
Apple Safari 9+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 17+ · Modern versions
Full support
flex-shrink property 99% supported

Bottom line: flex-shrink is safe for all modern projects. Combine with flex-grow and flex-basis for full control.

🎉 Conclusion

The flex-shrink property is a powerful tool for controlling the layout behavior of flex items within a flex container. By adjusting the shrink factor, you can create flexible and responsive designs that adapt to different screen sizes and container widths.

Experiment with different flex-shrink values to see how they affect the distribution of space in your flex layouts. For beginners, remember: default is 1, use 0 to lock an item, and higher numbers mean more shrinking.

💡 Best Practices

✅ Do

  • Use flex-shrink: 0 on logos, icons, and fixed sidebars
  • Combine with flex-grow and flex-basis for predictable sizing
  • Use proportional values (1, 2, 3) when items should shrink unequally
  • Set min-width: 0 on flex items that need to shrink below content size
  • Prefer the flex shorthand when setting all three values together

❌ Don’t

  • Apply flex-shrink on the flex container instead of its children
  • Treat shrink values as percentages — they are ratios
  • Expect shrinking when the container has enough space
  • Shrink buttons or links so small they become hard to tap
  • Forget that items with flex-shrink: 0 never give up space voluntarily

Key Takeaways

Knowledge Unlocked

Five things to remember about flex-shrink

Use these points when items must compress in tight layouts.

5
Core concepts
1 02

Default 1

Items shrink.

Default
📊 03

Proportional

Ratios, not %.

Key rule
0 04

flex-shrink: 0

Lock item size.

Pattern
🛠 05

Main axis

Overflow only.

Behavior

❓ Frequently Asked Questions

The flex-shrink property defines how much a flex item should shrink relative to other items when the flex container is too small along the main axis and items overflow their allotted space.
The default value is 1, which means flex items will shrink proportionally when the container does not have enough room for their combined sizes.
An item with flex-shrink: 2 gives up twice as much space as an item with flex-shrink: 1 when the container needs to shrink its children. The values are proportional ratios, not percentages.
No. flex-shrink applies to flex items (children), not the flex container itself. The parent needs display: flex or display: inline-flex.
flex-shrink only controls shrinking. The flex shorthand can set flex-grow, flex-shrink, and flex-basis together in one declaration, such as flex: 1 1 auto.

Practice in the Live Editor

Open the HTML editor, change shrink values on each item, and narrow the container to see how space is redistributed.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful