Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing <select> highlight color

How do I change the highlighting color of <select> that is the color that highlights <li> while cursor passes over it by using CSS?

like image 963
ArK Avatar asked Nov 03 '09 12:11

ArK


People also ask

How do you change the highlight color when selecting?

For example, the new highlight color will indicate selected text in Microsoft Word or folders that are open in the Finder. On the Apple menu, click System Preferences. Click General. In the Highlight color box, click the color that you want.

How do I change the highlight color on my cursor?

Open the Ease of Access settings by pressing the Windows logo key + U. Alternatively, select the Start Menu > Settings > Ease of Access. In the Ease of Access settings, select Mouse pointer from the left column. On the right (see image above), you will see four options for changing the colour of the pointer.


2 Answers

No idea what you mean about "the color that highlights <li>", but it sounds like you want to change the background colour of <option> elements. I tried it and it doesn't work, you always get the system color.

If you wanted to highlight the entire <select> element on mouseover, this kinda works:

select:hover { background-color: red; }

However the behaviour is different in different browsers. For example, Chrome doesn't highlight the options in the drop down; Firefox does, but then it doesn't change them back if you move the mouse away and they are still pulled down.

As has been stated on many, many similar questions, you can't reliably style form controls. See here for more details.

like image 145
DisgruntledGoat Avatar answered Oct 17 '22 12:10

DisgruntledGoat


You can't change the highlight color of the options through something like -> background:#f9f9f9

You can do something like this:

            select > option:hover{
                box-shadow: 0 0 10px 100px #FED20F inset;
                transition: all .2s ease-in-out;
            }
like image 41
Cosmin Avatar answered Oct 17 '22 10:10

Cosmin