css – 用font-awesome自定义一个选择

前端之家收集整理的这篇文章主要介绍了css – 用font-awesome自定义一个选择前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我实际上的:

HTML

<label class="select">
  <select name="email" id="email">
    <option>aaaa</option>
    <option>aaaa</option>
    <option>aaaa</option>
    <option>aaaa</option>
    <option>aaaa</option>
    <option>aaaa</option>
  </select>
</label>

CSS

.cforms select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;   
}


.select {
    position:relative;   
    display: -moz-inline-stack;
    display: inline-block;
    vertical-align: middle;
    zoom: 1;
    *display: inline;
    margin-top:40px;
}

.select:after {
  content: "\f0dc";
  font-family: FontAwesome;
  color: #000;
  padding:8px;
  position:relative;
  right:35px;
  top:0px;
  background:red;
  z-index:-1;
  width:10%;
  line-height:10%;
}

问题

实际上,我的选择附近没有箭头出现.

你能帮我一下吗

我在网上搜索的例子,但我不能使它的工作.

谢谢.

解决方法

也许是这样
.select {
    border: 1px solid #ccc;
    overflow: hidden; 
    height: 40px;    
    width: 240px;
    position: relative;
    display: block;
}

select{       
    height: 40px;
    padding: 5px;
    border: 0;
    font-size: 16px;       
    width: 240px;
   -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
.select:after {
    content:"\f0dc";
    font-family: FontAwesome;
    color: #000;
    padding: 12px 8px;
    position: absolute; right: 0; top: 0;
    background: red;
    z-index: 1;
    text-align: center;
    width: 10%;
    height: 100%;      
    pointer-events: none;
    Box-sizing: border-Box;   
}
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<label class="select">
    <select name="email" id="email">
        <option>aaaa1</option>
        <option>aaaa2</option>
        <option>aaaa3</option>
        <option>aaaa4</option>
        <option>aaaa5</option>
        <option>aaaa6</option>
    </select>
</label>

猜你在找的CSS相关文章