引导选择的CSS看起来相当繁重,因此您必须使用相当高的特定性进行覆盖…因此,最简单的方法是向包含月份选择的div添加一个ID,以便您可以专门针对它。(假设您不希望项目的大小选择与月div上的自定义大小相同)。
如果您擅长添加ID,以下是您需要的附加CSS:
.dropdown-menu>li>a {
text-align:center;
}
#month-select .bootstrap-select.btn-group {width:auto;}
#month-select.bootstrap-select.btn-group .dropdown-toggle,
#month-select.bootstrap-select.btn-group .dropdown-menu {
max-width:100px; /* or whatever width you want the select and dropdown to be */
min-width:100px; /* or whatever width you want the select and dropdown to be */
}
/* if you want to center the label in the dropdown button, not just the options
in the list, uncomment this:
.bootstrap-select.btn-group .dropdown-toggle .filter-option {
text-align:center;
padding-left:12px
}
*/
代码笔:
http://codepen.io/anon/pen/KzOpGJ