<select class="dropDown">
<option>mango</option>
<option>banana</option>
<option>pomegranate</option>
<option>papaya</option>
</select>
select.dropDown {
outline : none;
overflow : hidden;
text-indent : 0.01px;
text-overflow : '';
background : #666;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
}
select.dropDown::-ms-expand
display: none;
}
如评论中所述。IE 9及以下版本不支持<code>外观</code>属性。我在过去创造了类似的东西。基本上,我所做的是在select元素的箭头上方创建一个元素。
元素只是绝对定位,背景是静态的,与网页背景相同:
selectbox
{
position: relative;
width: 200px;
height: 200px
}
label
{
display: inline-block;
position: absolute;
right: 0;
height: 23px;
}
label:after
{
content: '';
width: 16px;
height: 23px;
position: absolute;
right: 2px;
color: #868583;
background: white;
border-left: 1px solid #868583;
padding-left: 2px;
}
label > select
{
float: right;
background: transparent;
border: 1px solid #575757;
color: #575757;
font-size: 14px;
letter-spacing: 2px;
font-family: Arial;
height: 100%;
}
您可能希望使用指针事件:none当您希望能够单击重叠元素时,请在重叠元素上单击code>。
我显示轮廓焦点,所以你看不到它勾勒出原始选择框宽度:
select::-moz-focus-inner {
border: 0;
}
select:focus
{
outline: none;
}
jsFiddle公司
这只是一个简单的例子,我做到了,希望你觉得有用。
使现代化
当用户使用IE时,您可以使用此代码,否则您可以使用您的代码。