Создание уникальных выпадающих списков с использованием CSS3
Перевод демонстрации от Lea Verou
HTML
<p><label class="custom-select">
Select your favorite food:
<select>
<option>Sushi</option>
<option>Blue cheese with crackers</option>
<option>Steak</option>
<option>Other</option>
</select>
</label></p>
CSS
p {
font-family: sans-serif;
}
label.custom-select {
position: relative;
display: inline-block;
}
.custom-select select {
display: inline-block;
border: 2px solid #bbb;
padding: 4px 3px 3px 5px;
margin: 0;
font: inherit;
outline:none; /* удаляем рамку, возникающую при фокусе */
line-height: 1.2;
background: #f8f8f8;
-webkit-appearance:none; /* удаляем стили по умолчанию движка Webkit */
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
/* решение на чистом CSS для движка Webkit */
@media screen and (-webkit-min-device-pixel-ratio:0) {
.custom-select select {
padding-right:30px;
}
}
/* так как стили по умолчанию для фокуса удалены, задаем свои стили */
.custom-select select:focus {
-webkit-box-shadow: 0 0 3px 1px #c00;
-moz-box-shadow: 0 0 3px 1px #c00;
box-shadow: 0 0 3px 1px #c00;
}
/* задаем стили стрелке */
.custom-select:after {
content: "▼";
position: absolute;
top: 0;
right: 0;
bottom: 0;
font-size: 60%;
line-height: 30px;
padding: 0 7px;
background: #bbb;
color: white;
pointer-events:none;
-webkit-border-radius: 0 6px 6px 0;
-moz-border-radius: 0 6px 6px 0;
border-radius: 0 6px 6px 0;
}
.no-pointer-events .custom-select:after {
content: none;
}