Is it possible to change the default background color of the select list option on hover?
HTML:
<select id="select"> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> </select>
select { -webkit-border-radius:25px; -moz-border-radius:25px; border-radius:25px; } select:hover { background-color:gren; } option:hover { background-color:yellow; } option { -webkit-border-radius:25px; -moz-border-radius:25px; border-radius:25px; color:blue; background-color:yellow; }
I have tried option :hover{background-color:red;}
, but it is of no use. Does anybody know how to do this?
You cannot change the style for these elements.
When the user hovers the cursor on that text, it changes the color of the text. CSS hover selector method is used for changing the color of the text when you move the cursor on that particular text. Note: The above syntax is used with class or id name to make a hover effect on that element.
To change the selected option background-color CSS style, we can set the style attribute of the select and option elements. to set the whole select element to background color 009966 and color FFF . Then we override the the styles in the option elements with style="background: white; color: black;" .
To change the color of your link on hover, use the :hover pseudo property on the link's class and give it a different color.
Currently there is no way to apply a css to get your desired result . Why not use libraries like choosen or select2 . These allow you to style the way you want.
If you don want to use third party libraries then you can make a simple un-ordered list and play with some css.Here is thread you could follow
How to convert <select> dropdown into an unordered list using jquery?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With