Html Bootstrap 选择菜单样式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37198699/
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
Bootstrap select menu styling
提问by Beginner
I am trying to give my <select>
menu a custom color and padding. As of now, It looks like this:
我正在尝试为我的<select>
菜单提供自定义颜色和填充。截至目前,它看起来像这样:
select {
display: block;
margin: 0 auto;
background-color: #2A3F54;
}
<select name="ad_account_selected" onchange="this.form.submit()" class="selectpicker" data-style="btn-primary">
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
</select>
I want a small gap between the menus and the left side and give it the color of my sidebar ( seen around the menu above ). However, the button remains in the default color and even if I add padding-left: 20px
the menu is stuck to the left side. Any help?
我希望菜单和左侧之间有一个小间隙,并给它我的侧边栏的颜色(在上面的菜单周围看到)。但是,按钮保持默认颜色,即使我添加padding-left: 20px
菜单也卡在左侧。有什么帮助吗?
回答by AndrewL64
Change your data-style
to btn-new
like this:
改变你data-style
对btn-new
这样的:
<select data-style="btn-new">
....
</select>
And then style that button like this:
然后像这样设置按钮的样式:
.btn-new {
background-color: #2A3F54;
}
Link to CodePen: http://codepen.io/anon/pen/pyBjrr
CodePen 链接:http://codepen.io/anon/pen/pyBjrr