I am trying to change a property of one element when hovering over another. In this case it is in my navigation.
What I have is a sub menu with a .class of .sub-menu
When I hover over the sub menu I want the parent of that element to change background color
The HTML code
<ul class="main-nav">
<li id"menu-item-1"><a>HOME</a></li>
<li id"menu-item-2"><a>About</a>
<ul class="sub-menu">
<li><a>Some Link</a></li>
</ul></li>
<li id"menu-item-3"><a>Services</a></li>
</ul>
So what I am trying to do is when I hover over the Sub Menu, I want the About Link to have a background-color.
The CSS code I been trying :
.sub-menu a:hover + #menu-item-2 a{
background-color:#FF0;
}
Also tried both of these:
.sub-menu a:hover ~ #menu-item-2 a{
background-color:#FF0;
}
.sub-menu a:hover > #menu-item-2 a{
background-color:#FF0;
}
Can someone please point me in the right direction here.
You can see the problem I have here - http://switchmedialab.co.za/switch-media/
When I hover over the service the background image "splat" appears but when I hover over the sub nav it disappear. I need it to stay there for the hover state.
Thanks.