Skip to content

Instantly share code, notes, and snippets.

@KirinHuang
Created March 30, 2017 03:13
Show Gist options
  • Save KirinHuang/b630ab4bb8ccfb044637fd78e0783590 to your computer and use it in GitHub Desktop.
Save KirinHuang/b630ab4bb8ccfb044637fd78e0783590 to your computer and use it in GitHub Desktop.
修改Select默认样式
/* 参考 */
select {
/*Chrome和Firefox里面的边框是不一样的,所以复写了一下*/
border: solid 1px #000;
/*很关键:将默认的select选择框样式清除*/
appearance:none;
-moz-appearance:none;
-webkit-appearance:none;
/*在选择框的最右侧中间显示小箭头图片*/
background: url("http://ourjs.github.io/static/2015/arrow.png") no-repeat scroll right center transparent;
/*为下拉小箭头留出一点位置,避免被文字覆盖*/
padding-right: 14px;
}
/*清除ie的默认选择框样式清除,隐藏下拉箭头*/
select::-ms-expand { display: none; }
/* 这一种有明显的bug,下拉菜单会比选择框长 */
#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%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment