Assume I have a select2 box inside a hidden div like this:
<form >
<div id="agent007">
<select name="slimy" id="slimy">
<option>Good</option>
<option>Bad</option>
</select>
</div>
</form>
Where the selection box has full width and the div is hidden
select{
width:100%
}
div{
display:none;
}
When I make the div visible, then the selection box has no full width.
$(document).ready(function(){
$('#slimy').select2();
$('#agent007').show();
});
How can I make a select2 box full width that was hiding in a invisible container?
Here is a jFiddle
select
element that you've initialized select2 to and you'll see that theselect
tag actually gets hidden and a newspan.select2-container
gets added and so the CSSselect { width: 100%; }
doesn't work. Hope this makes sense. – Thiouracil