twitter-bootstrap Bootstrap 3 多选插件作为表单元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20803189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 19:34:56  来源:igfitidea点击:

Bootstrap 3 multiselect plugin as form element

csstwitter-bootstraptwitter-bootstrap-3

提问by Misiu

I'm trying to add multiselect pluginto my form. I've managed to get everything working just fine (http://jsfiddle.net/Misiu/t2qaP/), but I would like to get that select to be 100% width.
I can add css by hand:

我正在尝试将多选插件添加到我的表单中。我已经设法让一切正常工作(http://jsfiddle.net/Misiu/t2qaP/),但我想让该选择为 100% 宽度。
我可以手动添加css:

 .btn-group, .btn-group .multiselect {
    width: 100% !important;
}

but maybe there is better way of doing this with bootstrap?

但也许有更好的方法用引导程序做到这一点?

here is my demo: http://jsfiddle.net/Misiu/t2qaP/

这是我的演示:http: //jsfiddle.net/Misiu/t2qaP/

回答by dima_horror

Again hello ;) See

再次你好 ;) 见

UPDATED

更新

http://jsfiddle.net/t2qaP/13/

http://jsfiddle.net/t2qaP/13/

select.multiselect,
select.multiselect + div.btn-group,
select.multiselect + div.btn-group button.multiselect,
select.multiselect + div.btn-group.open .multiselect-container{
    width:100% !important;
}

UPDATED 2You need to add buttonClassto multiselect options. But why do it? Looks so good. http://jsfiddle.net/t2qaP/14/

更新 2您需要添加buttonClass到多选选项。但为什么要这样做?看起来真好。 http://jsfiddle.net/t2qaP/14/

$('.multiselect').multiselect({
    includeSelectAllOption: true,
    buttonClass: 'form-control'
});

enter image description here

enter image description here

回答by nik

You might want to use buttonWidthoption if you do not wish to modify css. See below example.

buttonWidth如果您不想修改 css,您可能需要使用option。见下面的例子。

$('.multiselect').multiselect({
    includeSelectAllOption: true,
    buttonWidth: '411px'// here you need to specify width value
});

Demo Fiddle

演示小提琴

回答by BENARD Patrick

http://jsfiddle.net/t2qaP/12/

http://jsfiddle.net/t2qaP/12/

$('.input-daterange').datepicker();
$('.multiselect').multiselect({
    includeSelectAllOption: true,
    buttonClass : "col-sm-12"
});

The multiselect plugin allow to manage this.

多选插件允许管理这个。