Quick Tip to Stop Flexbox from Overflowing

・1 min read

I ran into an issue (yet again πŸ˜…) where my flex items weren't shrinking below a certain point in one browser but not another (e.g. it worked in Chrome but not Firefox). Turns out, it's a one-line fix: add min-width: 0; to the item.

.flex-container {
    display: flex;
}

.flex-item {
    flex: 1 1 0;
    min-width: 0;
}
DISCUSSION (6)
 
 

I always forget about that min-width:0 trick. Thank you for reminding me. :smile:

 

Haha, that's exactly why I wrote it down. I don't know how many times I've forgotten about it and had to find it again. πŸ˜…

 
 

The sad part is that it's so counterintuitive that it's bound to be forgotten again by everyone's memory.

 
Classic DEV Post from Jun 13 '18

How do you make time for your dev/tech projects?

Question I was about to write a long post about how I'm unable to al...

Martin Himmel
Web dev and aspiring game dev who loves to teach and dabbles in various languages.

Thanks for visiting dev.to

A Beginner's Guide to dev.to