html - 无法弄清楚为什么“已访问样式”不适用于链接
问题描述
有一个带有“about”类的链接“a”项目,我正在尝试创建一种访问过的紫色风格。但由于某种原因,它不是“已访问”样式的样式。谢谢你!
**html**
<header>
<a href="about.html" class="about">ABOUT</a>
</header>
**css**
a {
font-family: Gothic A1;
font-size: 18px;
text-decoration: none;
color: #000000;
}
about a:visited {
color: purple;
}
**hover animation**
a.about {
position: relative;
}
a.about:before {
content: '';
position: absolute;
width: 0;
height: 1px;
bottom: -2px;
left: 0px;
background: black;
visibility: hidden;
transition: all 0.3s ease-in-out;
}
a.about:hover:before {
visibility: visible;
width: 100%;
}
解决方案
应该是a.about:visited
,不是about a:visited
。
about a
查找作为元素子元素的所有锚标记about
。 a.about
查找about
该类的所有锚标记。
a {
font-family: Gothic A1;
font-size: 18px;
text-decoration: none;
color: #000000;
}
a.about:visited {
color: purple;
}
a.about {
position: relative;
}
a.about:before {
content: '';
position: absolute;
width: 0;
height: 1px;
bottom: -2px;
left: 0px;
background: black;
visibility: hidden;
transition: all 0.3s ease-in-out;
}
a.about:hover:before {
visibility: visible;
width: 100%;
}
<header>
<a href="about.html" class="about">ABOUT</a>
</header>
推荐阅读
- ansible - Ansible With_Together 循环迭代
- angular - 角材质拖放 - 合并元素
- html - Internet Explorer 中的 Angular Material 溢出问题
- c# - 当我从 C# 代码调用导入的 C++ 函数时,为什么会引发 AccessViolationException?
- kubernetes - 如何确保在 GCP 中将 Deployment/Pod 构建到当前项目的集群中?
- dockerfile - 带有 AMQP php 扩展的 Alpine
- string - 代号一:选择器按钮文本取消/确定未在 Android 设备上本地化
- outlook - VBA - 创建、编辑和发送不可见的电子邮件
- oracle - 使用 Azure 数据工厂按日期动态查询 Oracle 表
- java - 试图调用不存在的方法。尝试是从以下位置进行的: