I am using Select2 3.3.2
I have very very long options in the select. Example:
Select2 includes 'dropdownAutoWidth' parameter which uses javascript to attempt to be wide enough for the dropdown contents.
$('#whatever').select2({dropdownAutoWidth : true});
This at least works with Select2 3.4.3 - I don't know how much earlier it was introduced.
I used this and it worked perfect, only that it will affect all the select2
#select2-drop{
width: 400px !important;
}
The property you used is not for controlling the dropdown width. You can use the dropdownCssClass
property.
Here's a demo in jsFiddle.
JavaScript:
$(document).ready(function() {
$("#e1").select2({dropdownCssClass : 'bigdrop'});
});
CSS:
.bigdrop {
width: 600px !important;
}
Please note that for more recent versions there is now a better solution! See Dave Amphlett's answer
$("#e1").select2({ width: '100%' });
Try this. This will set the width of container to 100%
Try this.
$(".js-example-basic-single").select2({dropdownAutoWidth : true});
This worked for me..
.select2-container--krajee .select2-dropdown--below{
width:230px !important;
margin-left: -70px !important;
}