I do not know a form other than hack , because this element is rendered by the operating system. You can implement your own select (with <ul>
and <li
) or use one of several plugins that does this cross-browser .
A simple hack and the idea is to apply a shadow greater than the element, but turned inwards, using inset
:
select option:checked {
box-shadow: 0 0 150px #9b59b6 inset
}
<select>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
</select>
I used :checked
instead of :hover
because the second returns to the default appearance of the element when it loses hover. The :checked
for remains as long as the option is selected / checked.
Here's a comparison:
select.hover option:hover {
box-shadow: 0 0 150px #9b59b6 inset
}
select.checked option:checked {
box-shadow: 0 0 150px #9b59b6 inset
}
<h2>c/hover</h2>
<select class='hover'>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
</select>
<h2>c/checked</h2>
<select class='checked'>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
<option>lorem lorem lorem</option>
</select>