【发布时间】:2016-05-04 00:44:31
【问题描述】:
我是 CSS 的新手,并试图了解链接如何因状态更改而被修改。在我的场景中,当链接处于 visited 状态时,我想将 text-decoration 更改为 line-through。但是,无论是在 Mozilla 还是 Chrome 浏览器上,当链接处于 visited 状态时,text-decoration 的文本内容都不会更新为 line-through ,如下图。我哪里做错了?
当链接状态变为visited而text-decoration保持不变时,请通知颜色已更新(变为绿色);
注意:Mozilla 有一个关于同一问题的错误报告:Mozilla Bug #645786 和错误报告。 tag.class:state selector (a.:visited) 也会出现问题(参见 Demo #2)
演示#1
<!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>
Demo #2 --Selector 类
<!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>
【问题讨论】:
-
我认为这与:dbaron.org/mozilla/visited-privacy.. text-decoration is no option voor voor style the 'visited-state'..
-
很奇怪,如果是这样,为什么颜色会更新,而不是 text-decoration 属性?顺便说一句,你是荷兰人吗?你使用了 'voor' 而不是 'for' :)
-
哈,是的,我是荷兰人.. 我没有仔细阅读它,但似乎只有几个属性可以用于 :visited state(颜色、边框/轮廓等) ..
-
我在几分钟前看到了隐私问题限制,是的,文本装饰不在允许的样式属性列表中。
标签: html css google-chrome firefox text-decorations