Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make chosen as long as longest option

I am looking for a way to set the width of a chosen dropdown to the width of the longest option it has. The problem I have now is that when you pick a short item it will then wordwrap the other option and make the dropdown the same width as the option you picked. After some CSS playing I figured out how to turn off wordwrap for the results and removed width:100% so the results would be as wide as the longest option. This didn't have any affect on the dropdown itself though. Anyone know how to do this?

like image 985
Mav2287 Avatar asked Sep 16 '25 01:09

Mav2287


1 Answers

You should provide .chosen-drop with an automatic width and remove the word-wrap from the "li" inside chosen. Here is an example: http://codepen.io/dreamwave/pen/VjaEYm

And the CSS:

.chosen-results li {
  white-space:nowrap;
}
.chosen-container .chosen-drop {
  width:auto;
}

I hope I understand the issue correctly.

like image 72
DreamWave Avatar answered Sep 17 '25 20:09

DreamWave