为什么我不能为访问的链接覆盖文本装饰?

时间:2019-06-03 20:19:13

标签: css

请有人能解释为什么这似乎行不通吗?这很简单。我希望页面上的链接默认为不带下划线的蓝色,然后单击其中的一个,我希望将其变为带底线的紫色。但是,我的代码不起作用。

a {
	text-decoration: none;
	color: blue;
}

a:visited {
	text-decoration: line-through;
	color: purple;
}
<a href="http://www.google.com/" onclick="window.open(this.href); return false;">Google (click me)</a> &lt;-- Once clicked, it should have a line through it<br>
<!-- Had to add an onclick event as clicking the link doesn't seem to work without it -->
<a href="http://some-random-non-existant-site.com/">Non-existant Site</a>

https://jsfiddle.net/thefuzzy0ne/hfqdsr4z/

我尝试了text-decoration-linetext-decoration-style的各种组合,但似乎仍然没有任何效果。我通常不会在CSS上遇到很多麻烦,但这真让我发疯。

1 个答案:

答案 0 :(得分:3)

由于限于隐私原因,您只能访问已访问的伪类选择器的属性,因此只能设置以下样式:

color
background-color
border-color
border-bottom-color
border-left-color
border-right-color
border-top-color
column-rule-color
outline-color