I have a menu list as below:
<div id="menubar">
<ul class="menulist">
<li><a href="#">Home</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
What I'm trying to do is that initially, the font-color for the menu items is dark grey. But when user hovers over any menu item, that particular item remains dark grey but rest of the items turn light-grey.
I have following CSS.
#menubar a {
color: #202021;
display: block;
padding: 6px;
text-decoration: none;
}
#menubar a:hover {
display: block;
padding: 6px;
background-color: #97979B;
border-radius: 3px;
font-weight: bold;
}
#menubar .menulist:hover {
color: #747478;
}
But color
given in .menulist:hover
is not applied to menu items other than hovered item, while properties other than color
is applied to rest of the menu items when I hover on any menu item. I followed this SO question which had somewhat similar requirement.
How can I get this behavior with pure CSS?