Flexbox Content Overflow
Quick summary
Your flex items are shrinking too much or overflowing the container because flex defaults cause unexpected sizing behavior.
Why this happens
flex-shrink defaults to 1, causing items to shrink below their content size
Long text or URLs without overflow handling break the layout
min-width defaults to auto in flexbox, preventing shrinking below content size
Minimal example
.container { display: flex; }
.item {
/* flex-shrink: 1 by default */
/* min-width: auto prevents shrinking below content */
/* Long text overflows the container */
}.container { display: flex; }
.item {
min-width: 0; /* Allow shrinking below content size */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}Setting min-width: 0 overrides the default auto value, allowing the flex item to shrink. overflow: hidden and text-overflow: ellipsis handle long text gracefully.
How to diagnose
Inspect the flex items in DevTools — check their computed width
Look for content that is wider than the available space
Check flex-shrink and min-width values on the items
How to fix
Set min-width: 0 on flex items to allow them to shrink below content size
Add overflow: hidden and text-overflow: ellipsis for long text
Set flex-shrink: 0 on items that should not shrink
Use flex: 0 0 auto for fixed-size items
How to prevent
Set min-width: 0 or min-height: 0 on flex items that contain long content
Use word-break: break-word or overflow-wrap: break-word for text
Related Resources
Related Glossary
Related Lessons
- CSS Flexbox
Learn flexbox sizing.