用纯css改变下拉列表select框的默认样式

html

<div id="parent">
  <select>
      <option>what</option>
      <option>the</option>
      <option>hell</option>
  </select>
</div>

css

#parent{
    background: url('https://raw.githubusercontent.com/ourjs/static/gh-pages/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%;    
}

参考文档:http://ourjs.com/detail/551b9b0529c8d81960000007

posted @ 2020-03-16 16:36  代码沉思者  阅读(263)  评论(0编辑  收藏  举报