Lev*_*glu 0 html css firefox google-chrome text-decorations
我是CSS的新手,试图了解如何根据状态更改来修改链接。在我的情况下,我想将链接更改text-decoration为“ line-through已访问”状态。但是,在Mozilla和Chrome浏览器上,当链接处于“ 访问”状态时,text-decoration文本内容都不会更新,如下所示。我哪里做错了?line-through
请注意,当链接状态更改为已访问但链接text-decoration保持不变时,颜色会更新(变为绿色)(请参阅演示1);
注意:Mozilla有关于同一问题的错误报告:Mozilla错误#645786和错误报告。tag.class:state 选择器(a.:visited)也会出现问题(请参阅演示#2)
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
color: red;
text-decoration: none;
}
a:visited {
color: green;
text-decoration: line-through;
}
a:hover {
color: blue;
}
a:active {
color: yellow;
}
</style>
</head>
<body>
<p>
<b>
<a href="http://google.com" target="_blank">This is a link</a>
</b>
</p>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<style>
a.linkClass:link {
color: red;
text-decoration: none;
}
a.linkClass:visited {
color: green;
text-decoration: line-through;
}
a.linkClass:hover {
color: blue;
}
a.linkClass:active {
color: yellow;
}
</style>
</head>
<body>
<p>
<b>
<a class="linkClass" href="http://google.com" target="_blank">This is a link</a>
</b>
</p>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
设置访问链接的样式存在限制。
限制访问的链接样式
您仍然可以在视觉上对访问的链接进行样式设置,但是现在可以使用的样式受到限制。只有以下属性可以应用于访问的链接:
Run Code Online (Sandbox Code Playgroud)color background-color border-color (and its sub-properties) outline-color The color parts of the fill and stroke properties
text-decoration 由于用户的隐私问题,不允许样式设置。