gpt4 book ai didi

html - 我是刚刚发现了 CSS 中的错误还是忽略了什么?

转载 作者:行者123 更新时间:2023-11-28 15:49:37 24 4
gpt4 key购买 nike

我在全局范围内为我的所有 a 链接设置了这些样式。我无法覆盖同一页面上 div 中的链接样式。

a, a:visited{
outline: 0;
cursor: pointer;
color: inherit;
text-decoration: none;
}

a:hover{
text-decoration: underline;
}

现在我想重写 anchor 链接的样式,以便在悬停时将其颜色更改为白色,但仅限于多个类的 div 和通知容器,例如这个......

<div class="unseen notificationContainer">                     
<a href="profile?customerId=1365764036258">
<strong>robert</strong>
</a>
sent you a friend request
<a href="friend_request?type=accept&amp;notificationId=1365764054463">
Accept
</a>
<a href="friend_request?type=reject&amp;notificationId=1365764054463">
Reject
</a>
</div>

所以我将以下内容添加到我的 CSS 中

.unseen{
background: #09f;
color: #fff;
}

.unseen a :hover{
color: #fff;
text-decoration: underline;
}

当页面加载时,将鼠标悬停在第一个链接上会使它的颜色变为白色,但其他三个链接的背景颜色为蓝色。在过去的一个小时里,我一直在研究这个问题,这不仅仅是令人恼火。 notificationContainer 的样式如下

.notificationContainer{
width: 390px;
float: left;
border-bottom: solid 1px #eee;
padding: 5px;
}

提前致谢。

最佳答案

CSS 不可能有错误,只有浏览器可以(除非你指的是 CSS 规范中的错误等)。

也就是说,这是您代码中的错误,而不是浏览器中的错误:

.unseen a :hover{
color: #fff;
text-decoration: underline;
}

a:hover 之间的空格表示 :hoverwithin 中的任何元素a,很像 .unseen a 表示 .unseen 中的 a 元素,因此这将不起作用。您需要删除该空间:

.unseen a:hover{
color: #fff;
text-decoration: underline;
}

关于html - 我是刚刚发现了 CSS 中的错误还是忽略了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15971360/

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