简体   繁体   English

CSS3有选择地禁用悬停效果

[英]CSS3 disable hover effect selectively

I have an unnumbered list containing multiple items - some items are 'headings', most items are links. 我有一个包含多个项目的未编号列表-一些项目为“标题”,大多数项目为链接。

At present, I have the following CSS for my list: 目前,我的清单中包含以下CSS:

#result-side-menu li:hover {
  background-color: rgba(0,0,0,0.15);
}

I want to be able to disable the hover only on the heading list items while maintaining it on all others. 我希望能够仅在标题列表项上禁用悬停,同时将其保留在所有其他项上。 My best (and still unsuccessful) attempt so far was to do this: 到目前为止,我最好的尝试(但仍然没有成功)是这样做的:

#result-side-menu.li-no-hover li:hover {
  background-color: none;
}

and then to apply the class="li-no-hover" to the heading list items. 然后将class="li-no-hover"应用于标题列表项。

Is there a way of achieving what I'm trying to do? 有没有办法实现我想要做的事情?

If you apply class="li-no-hover" to your li elements you don't want the hover effect, then this is the css you want: 如果将class="li-no-hover"应用于li元素,则不需要悬停效果,那么这就是您想要的css:

#result-side-menu li.li-no-hover:hover {
    background-color: transparent;
}

You can try this: 您可以尝试以下方法:

#result-side-menu li.li-no-hover:hover {
  opacity:1;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM