Question : Color of <li> when hovering?

Hi,

I'd like to change the color of a <li> item when the mouse is hovered over it. I'm a bit uncertain about how to define it given my current css defs:

 
  #myList li, .default {
      background-color: white;
   }

  #myList li.red {
      background-color: red;
  }

  #myList li.green {
      background-color: green;
  }

so sometimes a particular list item might have the 'red' style applied to it, sometimes the 'green', othertimes just the default style.

How would I add a hover style which changes the color to yellow for example?

Thanks

Answer : Color of <li> when hovering?

you can add the :hover pseudo tag to your stylesheet, such as:

#myList li.red:hover {
  background-color: yellow;
}

If you want to have the background be yellow for any li, whether they be class red, green or otherwise, I think you can do:

#myList li:hover {
  background-color: yellow;
}

I'm pretty sure as long as it appears later in the stylesheet than the others it will take precedence.
Random Solutions  
 
programming4us programming4us