我想从下拉框中删除默认的箭头,并使用自定义图标。 根据SO上以前的答案,我发现这是不可能的(在主流浏览器中无法实现)。唯一的可能性是将选择框包装在一个div内,将其宽度设置为大于div宽度,并设置overflow:hidden。
我正在尝试以下内容,但它不起作用。我做错了什么?
.selectParent {
width: 80px;
overflow: hidden;
}
.selectParent select {
width: 100px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 2px 30px 2px 2px;
border: none;
background: transparent url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/br_down.png") no-repeat right center;
}
<div class="selectParent">
<select>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</div>
JSFiddle: http://jsfiddle.net/gcPmC/