My goal is to apply a unique background color to each menu li element when hovered over, and I want to accomplish this using CSS2.
<ul>
<li>
<li>
<li>
<li>
</ul>
I managed to add a background color to the first element with the following code:
nav ul > li:hover:first-child a { background-color:red !important; }
When I attempt to apply a different background to the second element, the hover effect for the next element only triggers when hovering over the first element.
This is the code I have so far:
nav ul > li:hover:first-child a { background-color:red !important; }
nav ul > li:hover:first-child + li a { background-color:blue !important; }
Is there a correct way to achieve this using CSS2?
I'm hoping to gain insight from Boltclock's answer in the following link.
How do I get the nth child of an element using CSS2 selectors?
Any assistance on this matter would be greatly appreciated.