我想用字體真棒圖標替換默認的選擇框箭頭。它的樣式是我想要的,但是當我點擊自定義箭頭時,下拉菜單不會打開。如果我點擊選擇框上的其他地方,事情就會正常工作。我已將選擇框的z索引設置爲高於箭頭的z索引。不知道問題是什麼。自定義下拉箭頭單擊問題
body {
padding: 30px;
}
.dropdown {
position: relative;
width: 300px;
}
.dropdown select {
outline: none;
margin: 0;
padding: 0;
border: none;
border-radius: 0;
box-shadow: none;
background: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border-bottom: 1px solid;
padding: 0 6px 0 6px;
cursor: pointer;
width: 100%;
z-index: 2;
}
.dropdown select:hover {
border-color: rgba(221, 221, 221, 0.5);
background: rgba(221, 221, 221, 0.5);
}
.dropdown::after {
position: absolute;
font-family: "FontAwesome";
color: black;
content: "\f107";
bottom: 1px;
right: 4px;
}
.dropdown:hover::after {
color: gray;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="dropdown">
<select id="exampleSelect1">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</div>
我的頁面有背景。如果我這樣做,箭頭在後面,不能被看到。 – takeradi
Gotchya。我更新瞭解決方法。 – DACrosby