0

I'm trying to change the background color on hover in select, I tried many ways and It wont change.Really appreciate If you can help,

.selector {

  background-color: #252525;
  color: #fff;
  border: none;
  border: 1px solid #595E57;
  padding: 5px;
  width: 150px;
}

.selector option:hover{

  background-color: #1BA1E2 !important;
}
<select name=""  class="selector">
             <option value="">Select</option>
             <option value="">Select</option>
</select>

enter image description here

Mishen Thakshana
  • 143
  • 1
  • 12

2 Answers2

1

Form elements are rendered by the OS and not the browser, so the CSS isn't always (or even 'is rarely') applied. There are ways to change the highlight color in Firefox, by adding a box-shadow to the CSS for option:hover, but this is browser-specific.

Try something like box-shadow: 0 0 10px 10px #1BA1E2 inset;

At the end it's not worth it. Think on mobile first. On iOS the options will be rendered in a very own way anyway. There are no colors.

WebWorker
  • 413
  • 3
  • 9
1

.selector {

  background-color: #252525;
  color: #fff;
  border: none;
  border: 1px solid #595E57;
  padding: 5px;
  width: 150px;
  overflow:hidden;
}
.selector option{
padding:5px;
}
.selector option:hover{
  background-color: #1BA1E2 !important;
}
<select onfocus='this.size=10;' onchange='this.size=1; this.blur();' name=""  class="selector">
             <option value="">Select1</option>
             <option value="">Select2</option>
             <option value="">Select3</option>
             <option value="">Select4</option>
</select>
Ahmad
  • 816
  • 2
  • 9
  • 15