在表单上使用select时,有没有办法更改箭头位于右侧的背景颜色?我也可以改变箭头本身的颜色吗?我使用最新的稳定版本的bootstrap,不知道他们是否有任何内置或如果有CSS可以做到这一点。我附上了一张现在看起来像的图片以及我想把它改成
的图片答案 0 :(得分:0)
我在此页面上找到了解决方案:https://codepen.io/bephf/pen/ogNBYW
<div class="select-style">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</div>
然后是CSS样式:
.select-style {
padding: 0;
margin: 0;
border: 1px solid #ccc;
width: 120px;
border-radius: 3px;
overflow: hidden;
background-color: #fff;
background: #fff url("path to arrow image") no-repeat 90% 50%;
}
.select-style select {
padding: 5px 8px;
width: 130%;
border: none;
box-shadow: none;
background-color: transparent;
background-image: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.select-style select:focus {
outline: none;
}
答案 1 :(得分:0)
您需要阻止其自定义的正常箭头。 Сolors供您选择))
知道问题:当您单击箭头时,自定义菜单不会出现。我需要一点js
.select-style {
padding: 0;
margin: 0;
border: 1px solid #ccc;
width: 120px;
border-radius: 3px;
overflow: hidden;
background-color: #fff;
background: #fff url("http://www.scottgood.com/jsg/blog.nsf/images/arrowdown.gif") no-repeat 90% 50%;
}
.select-style select {
padding: 5px 8px;
width: 130%;
border: none;
box-shadow: none;
background-color: transparent;
background-image: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.select-style select:focus {
outline: none;
}
.select-style {
position: relative;
}
.arrow {
position: absolute;
right: 0;
top: 0;
z-index: 100;
background-color: red;
color: blue;
line-height: 2;
}
.select-style:hover .arrow {
color: lightblue;
}
<div class="select-style">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<div class="arrow">▼</div>
</div>