gpt4 book ai didi

css - 如果它属于两个类,则将悬停应用于无序列表项

转载 作者:太空宇宙 更新时间:2023-11-04 04:31:11 25 4
gpt4 key购买 nike

除了第一个,我试图在悬停时突出显示列表项。

这是 html:

  ...
<ul class="topmenulist">
<li><a href="#" class="active" >Home</a></li>
<li><a href="#" class="notactive" >What we do</a></li>
<li><a href="#" class="notactive" >Projects</a></li>
<li><a href="#" class="notactive" >Contact</a></li>
</ul>
...

这不起作用:

  .notactive.topmenulist li:hover{ 
background-color: #EAEAEA;
}

这有效,但它也适用于我不想要的第一个:

  .topmenulist li:hover{ 
background-color: #EAEAEA;
}

谢谢

最佳答案

.topmenulist li:hover a:not(.active) {
background-color: #EAEAEA;
}

jsFiddle

或者更简单:

.topmenulist li:hover a.notactive {
background-color: #EAEAEA;
}

jsFiddle

编辑:如果您想突出显示所有 li.noactive你应该申请:hoverul ( .topmenulist ):

.topmenulist:hover li a.notactive {
background-color: #EAEAEA;
}

jsFiddle

关于css - 如果它属于两个类,则将悬停应用于无序列表项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17259973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com