Hover effect for parent unordered list inherited by child list

Posted by elvista on Stack Overflow See other posts from Stack Overflow or by elvista
Published on 2010-05-10T16:31:10Z Indexed on 2010/05/10 16:34 UTC
Read the original article Hit count: 444

Filed under:
|
|

I have a simple menu

<ul id="menu">
<li class="leaf"><a href="#">Menu Item 1</a></li>
<li class="leaf"><a href="#">Menu Item 2</a></li>
<li class="expanded"><a href="#">Menu Item 3</a>
    <ul>
       <li class="leaf"><a href="#">Menu Item a</a></li>
       <li class="leaf"><a href="#">Menu Item b</a></li>
       <li class="leaf"><a href="#">Menu Item c</a></li>
   </ul>
</li>
<li class="leaf"><a href="#">Menu Item 4</a></li>
</ul>

and

ul#menu li a:hover {font-weight:bold;}

The problem I am facing is when I hover above a ul li li, the parent as well as all its siblings gets the hover effect. I only want the list item I hovered above to get the effect.

I tried ul#menu li.leaf a: hover {..}, ul#menu li.expanded a: hover {..} , but even in that case, when I hover above li.expanded, it's child inherits the style.

How do I fix this?

© Stack Overflow or respective owner

Related posts about css

Related posts about list