Barry Fruitman Barry Fruitman - 3 years ago 82
CSS Question

How do I constrain a <select> to its parent div's width?

My webpage has a

menu within a
parent. If the menu contains a very wide item, it overflows its parent's width (when closed). How do I truncate it instead?

I tried
flex-shrink: 1
but nothing happened. Am I using it correctly? Do I apply it to the
or the wide
? Or something else?

Answer Source

I'm using flex display but flex-shrink: 1 by itself didn't work, but it worked when I added width: 100%. Not sure why that made a difference but it did.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download