当我在代码中的原始样式之后应用 :visited 样式时,:visited 样式会覆盖默认样式,这不会产生链接已被访问的效果。
我想要的默认样式是 .btn
访问链接后我想要的样式是 .btn:visited
我尝试将 :visited 样式移动到 :hover 样式的上方和下方。根据我的阅读,:visited 样式应该高于 :hover 样式。但它会覆盖我想以现在的方式应用于链接的默认样式。
<!-- I want this styling to be the default -->
.btn {
margin-left: 10px;
margin-right: 10px;
background-color: darkgrey;
color: darkred;
}
<!-- I want this styling to be applied only once visted -->
.btn:visited {
color: orange;
}
.btn:hover {
/* Applies to links under the pointer */
font-weight: bold;
background-color: darkgrey;
color: darkred;
}
我的预期结果是链接的背景为深灰色,文本颜色为深红色。
实际结果是只有橙色文本颜色的链接,我只在访问链接后才想要它。