By default, nothing should be applying a width to the .multiselect-container
, so it will take up as much room as it needs in order to display all the items on a single line:
If however, something is applying a width to the .multiselect-container
, you'll encounter the problem you identified:
The problem is that bootstrap multiselect uses a dropdown-menu to which the bootstrap library applies the following code:
<!-- language: lang-css -->
.dropdown-menu>li>a { white-space: nowrap; }
In order to fix this, we can return white-space to it's normal wrapping mode with the following css:
<!-- language: lang-css -->
.multiselect-container > li > a { white-space: normal; }
Couple more notes:
maxHeight
takes the number of pixels, so passing in 5
will make the control only 5px high. You should pass in something like maxHeight: 200
enableCaseInsensitiveFiltering
does the same thing as enableFiltering
so you don't need both. Decide whether you want case sensitivity or not and then set either one to true
Update with further explanation
@user2105811, You do not need to target the label specifically and you do not need to use !important
here's the HTML structure and CSS that is generated for this solution:
- Notice that
white-space
is always inherited from the parent, so targeting label
will do the same thing as targeting a
, but will address the problem at it's root.
- The original bootstrap code has the same degree of specificity as the selector being used to fix it. Meaning it will override it as long as your custom CSS is placed after the bootstrap css which should always be the case. If it's not working, I suspect you are not doing this.