TeaTime TeaTime - 19 days ago 6
HTML Question

Using Font Awesome as Select Icon

Lets say i have the following Button



button {
background-color: #fff;
border: 1px solid #122e45;
border-radius: 5px;
font-size: 12px;
margin-right: 5px;
outline: medium none;
padding: 7px 30px 7px 10px;
position:relative;
}

button i{
right: 10px;
top: 10px;
position:absolute;
}

<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<button>SomeButton <i class="fa fa-angle-down"></i></button>





How do i recreate this one as Select ? Because some simple

select {
background-color: #fff;
border: 1px solid #122e45;
border-radius: 5px;
font-size: 12px;
margin-right: 5px;
outline: medium none;
padding: 7px 30px 7px 10px;
position:relative;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
</style>
<select>
<option selected="selected">Relevanz <i class="fa fa-angle-down"></i></option>
<option>Datum <i class="fa fa-angle-down"></i></option>
</select>


doestn work at all

I already checked Font Awesome but there is no example given for this problem

Answer

Using this and this you can try the following:

JSfiddle

select {
  padding: 4px;
  margin: 0;
  background: #fff;
  color: #888;
  border: none;
  outline: none;
  display: inline-block;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  width: 150px;
  -webkit-border-radius: 0px;
  -moz-border-radius: 0px;
  border-radius: 0px;
}
/* Targetting Webkit browsers only. FF will show the dropdown arrow with so much padding. */

@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select {
    padding-right: 18px
  }
}
label {
  position: relative
}
label:after {
  content: "\f078";
  font-family: "FontAwesome";
  font-size: 11px;
  color: #aaa;
  right: 8px;
  top: 4px;
  padding: 0 0 2px;
  position: absolute;
  pointer-events: none;
}
label:before {
  content: '';
  right: 4px;
  top: 0px;
  width: 23px;
  height: 18px;
  background: #fff;
  position: absolute;
  pointer-events: none;
  display: block;
}
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />

<label>
  <select>
    <option selected="selected">Relevanz
      <label><i class="fa fa-angle-down"></i>
      </label>
    </option>
    <option>Datum <i class="fa fa-angle-down"></i>
    </option>
  </select>
</label>