Css导航菜单悬停

Css导航菜单悬停,css,colors,hover,Css,Colors,Hover,因此,我使用css创建了一个导航菜单,我只有一个问题,当我将鼠标悬停在子菜单上时,我希望顶部菜单将字体颜色更改为白色,以便人们知道他们正在查看哪个子菜单 <li style="width:150px" id="lovedating"><a href="#">Love & Dating</a> <div id="love&dating" class="belownav"> <div class="ontop">Love &

因此,我使用css创建了一个导航菜单,我只有一个问题,当我将鼠标悬停在子菜单上时,我希望顶部菜单将字体颜色更改为白色,以便人们知道他们正在查看哪个子菜单

<li style="width:150px" id="lovedating"><a href="#">Love & Dating</a>
<div id="love&dating" class="belownav">
<div class="ontop">Love & Dating</div>
<div class="navitem"><ul id="navitemul">
<li class="marright"><a href="http://www.curious-howto.com/love-dating/broken-hearths/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/Broken-Hearths.jpg" width="63" height="40" /><span class="marleft">Broken Hearths</span></a></li>
<li class="marright"><a href="http://www.curious-howto.com/love-dating/dating/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/Dating.jpg" width="63" height="40" /><span class="marleft">Dating</span></a></li>
<li class="marright"><a href="http://www.curious-howto.com/love-dating/dating-humor/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/Dating-Humor.jpg" width="63" height="40" /><span class="marleft">General Health</span></a></li>
<li class="marright"><a href="http://www.curious-howto.com/love-dating/flirting/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/Flirting.jpg" width="63" height="40" /><span class="marleft">Flirting</span></a></li>
<li class="marright"><a href="http://www.curious-howto.com/love-dating/kissing/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/Kissing.jpg" width="63" height="40" /><span class="marleft">Kissing</span></a></li>
<li class="marright"><a href="http://www.curious-howto.com/love-dating/physical-relationships/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/Physical-Relationships.jpg" width="63" height="40" /><span class="marleft">Physical Relationships</span></a></li>
<li class="marright"><a href="http://www.curious-howto.com/love-dating/relationships/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/relationships.jpg" width="63" height="40" /><span class="marleft">Relationships</span></a></li>
<li class="marright"><a href="http://www.curious-howto.com/love-dating/weddings/"><img class="fl" src="http://www.curious-howto.com/images/2013/04/weddings.jpg" width="63" height="40" /><span class="marleft">Weddings</span></a></li>
</ul></div>
</div></li>
但没有效果,请告知:)谢谢


请访问我的网站www.quirier-howto.com并查看菜单,如果您想了解更多我的意思:)

我认为代码应该是

<ul id="navitemul">
<li style="width:150px" id="lovedating"><a href="#">Love & Dating</a>
</li> <!-- Close the <li> tag here -->

因为您的
  • 标记包含所有的
    ,所以样式将继承,我将尝试使用jQuery

    $('ul#navitemul').hover(function(){ // change color of the link to white
           $(this).closest('#lovedating a').css('color', '#FFF');
      },function(){ // change the color of the link back
           $(this).closest('#lovedating a').css('color', '#009');
    });
    

    直到css4。您需要一个父选择器,它将是css4的一部分,但这是将来的事情。
    $('ul#navitemul').hover(function(){ // change color of the link to white
           $(this).closest('#lovedating a').css('color', '#FFF');
      },function(){ // change the color of the link back
           $(this).closest('#lovedating a').css('color', '#009');
    });