用纯CSS改变下拉列表Select框的默认样式
程序员文章站
2022-03-02 15:25:48
...
HTML
<div id="parent">
<select>
<option>what</option>
<option>the</option>
<option>hell</option>
</select>
</div>
CSS
#parent{
background: url('http://ourjs.github.io/static/2015/arrow.png') right center no-repeat;
/* the width and the height of your image */
width: 100px;
height: 30px;
overflow: hidden;
border: solid 1px #ccc;
}
#parent select{
-webkit-appearance:none;
-moz-appearance:none;
appearance:none;
background:transparent;
border:none;
padding-left:10px;
width: 120px;
height:100%;
}
效果:Demo
推荐阅读