admin管理员组文章数量:1026989
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%'
});
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%'
});
本文标签: javascriptChosen with width equal to the largest optionStack Overflow
版权声明:本文标题:javascript - Chosen with width equal to the largest option - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745608950a2158891.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论