小编Fra*_*key的帖子

css:悬停在ul li上,不要将其悬停在ul li.dont-hover上,而不是覆盖

我想知道以下是否可能,在最后半小时搜索它时找不到它所以在这里.

我有一个无序列表

<ul>
 <li class="head">Day 1</li>
 <li>10:00</li>
 <li>12:00</li>
 <li class="head">day 2</li>
 <li>10:00</li>
 <li>14:00</li>
</ul>

<style>
ul li.head {
 background-color:green;
}
ul li:hover {
 background-color:red;
}
</style>
Run Code Online (Sandbox Code Playgroud)

现在,如果你将鼠标悬停在li.head上,它也会得到一个红色的背景.

所以我的问题是,是否有类似的东西

<style>
ul li.head {
 background-color:green;
}
ul li:hover !for li.head {
 background-color:red;
}
</style>
Run Code Online (Sandbox Code Playgroud)

我只是想知道在css中是否有这样的东西,我不是在寻找其他解决方案,这不是我的观点.

为了说清楚,我不想像它那样覆盖它

<style>
ul li.head {
 background-color:green;
}
ul li:hover {
 background-color:red;
}
ul li.head:hover {
 background-color:green;
}
</style>
Run Code Online (Sandbox Code Playgroud)

我也不想要

<style>
ul li:hover {
 background-color:red;
}
ul li.head {
 background-color:green;
}
</style>
Run Code Online (Sandbox Code Playgroud)

我只是想知道在CSS中是否有类似的东西.

注意:你可能会想到为什么你可以简单地用这个代码覆盖它,但我真的简化了这个例子.

css hover

0
推荐指数
1
解决办法
290
查看次数

标签 统计

css ×1

hover ×1