Vic*_*tor 6 twitter-bootstrap jquery-select2
在select2 4.0版本中有一个主题选项.但是在文档中我找不到该选项意味着什么,我怎样才能创建自定义主题(https://select2.github.io/examples.html)
我发现select2的bootstrap 3主题,但它似乎只适用于3.5版本.
那么我可以为select2最新版本(4.0)创建自定义主题吗?基本上我需要bootstrap 3样式,最好是LESS文件
@fk正在为Select2 4.0.0开发Bootstrap 3主题.
https://github.com/select2/select2-bootstrap-theme
目前没有关于为Select2 4.0.0创建主题的任何文档,但它可能有助于查看选择器的默认主题的SCSS.
如果您想使用 Kevin Brown 的回答中的 bootstrap 样式
https://github.com/select2/select2-bootstrap-theme
您将此 css 文件添加到您的页面,保持默认的 select2 样式
<link href="/select2-bootstrap-theme/select2-bootstrap.min.css" type="text/css" rel="stylesheet" />Run Code Online (Sandbox Code Playgroud)
然后设置主题
$("#elem").select2({theme:"bootstrap"});Run Code Online (Sandbox Code Playgroud)
此外,在 .input-group 包装元素上使用.select2-bootstrap-prepend和.select2-bootstrap-append 类来无缝地对按钮和选择进行分组。