我已经设法在我的项目中包含 Flat UI(免费)CSS,它为我的按钮和文本框(以及普通文本)设置样式,但是我无法同时设置演示站点上显示的下拉按钮的样式。
问题是,如果我将类select-block
(在演示中)添加到select
我的 HTML 中的项目中,则下拉菜单根本没有样式。
我更喜欢 designmodo 网站的免费下拉教程。
HTML
<div id="switch">Hover me
<ul id="switch-menu">
<li><a id="ml">menu 1</a></li>
<li><a id="en">menu 2</a></li>
</ul>
</div>
CSS
#switch {
width: 500px;
height: 50px;
background-color: #3498db;
color: white;
cursor: pointer;
padding: 13px 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: background-color 0.5s ease 0s;
-moz-transition: background-color 0.5s ease 0s;
-ms-transition: background-color 0.5s ease 0s;
-o-transition: background-color 0.5s ease 0s;
transition: background-color 0.5s ease 0s;
}
#switch-menu {
background: #3498db;
position: absolute;
top: 48px;
left: 10px;
opacity: 0;
margin: 0;
padding-left: 0;
-webkit-transition: opacity 0.5s ease 0s;
-moz-transition: opacity 0.5s ease 0s;
-ms-transition: opacity 0.5s ease 0s;
-o-transition: opacity 0.5s ease 0s;
transition: opacity 0.5s ease 0s;
}
#switch-menu li {
list-style: none;
height: 0;
overflow: hidden;
-webkit-transition: height 0.5s ease 0s;
-moz-transition: height 0.5s ease 0s;
-ms-transition: height 0.5s ease 0s;
-o-transition: height 0.5s ease 0s;
transition: height 0.5s ease 0s;
}
#switch-menu li a {
display: block;
color: white;
width: 120px;
text-decoration: none;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.5s ease 0s;
-moz-transition: all 0.5s ease 0s;
-ms-transition: all 0.5s ease 0s;
-o-transition: all 0.5s ease 0s;
transition: all 0.5s ease 0s;
}
#switch:hover ul {
opacity: 1;
}
#switch:hover ul li {
height: 40px;
overflow: visible;
}
#switch:hover ul li a:hover {
padding-left: 15px;
background-color: #4aa3df;
}
您已经使用了 Flat UI 附带的 Selectpicker jQuery 插件(它取代了 Bootstrap Selectpicker 添加了更多选项)并以下列方式初始化它:
$('select[name="myselect"]').selectpicker({
style: 'btn-primary',
menuStyle: 'dropdown-inverse'
});
(替换myselect
为您的选择框的名称。)