I'm trying to make the DropDownList with the JQuery-Chosen in it reacts like all others "normal" DropDownLists, matching the width equal to the largest option on the DDL. I tried some different approaches to get this done, using css and JQuery, but all I tried became ugly.
At the official page of Chosen, .html , it says:
The width of the Chosen select box. By default, Chosen attempts to match the width of the select box you are replacing. If your select is hidden when Chosen is instantiated, you must specify a width or the select will show up with a width of 0.
Any way to workaround this?
Workspace: /
$('.chosen').chosen({
width: 'auto'
});
I'm trying to make the DropDownList with the JQuery-Chosen in it reacts like all others "normal" DropDownLists, matching the width equal to the largest option on the DDL. I tried some different approaches to get this done, using css and JQuery, but all I tried became ugly.
At the official page of Chosen, http://harvesthq.github.io/chosen/options.html , it says:
The width of the Chosen select box. By default, Chosen attempts to match the width of the select box you are replacing. If your select is hidden when Chosen is instantiated, you must specify a width or the select will show up with a width of 0.
Any way to workaround this?
Workspace: http://jsfiddle/cdtn0ko7/
$('.chosen').chosen({
width: 'auto'
});
Share
Improve this question
asked Apr 1, 2015 at 19:37
Luís FernandoLuís Fernando
1332 silver badges12 bronze badges
2
-
I removed
{width: 'auto'}
and it worked. If that's what you're going for that is. Edit never mind it consumes the entire width of the area. – Wild Beard Commented Apr 1, 2015 at 19:44 - Small fix, now loading the bootstrap-chosen: jsfiddle/5yL5qy8o – Luís Fernando Commented Apr 1, 2015 at 20:23
3 Answers
Reset to default 4Try this out for size. :D
Fiddle
$('.chosen').chosen();
.form-control {
width: auto;
}
Not sure if I got the question right, but since you are using Bootstrap, you can just do something like this on the css:
.chosen-drop {
position: inherit !important;
}
I tried using this following code and it worked, check this out:
$('.chosen').chosen({
width: '100%'
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745608951a4635836.html
评论列表(0条)