文字修饰不适用于访问状态链接

Lev*_*glu 0 html css firefox google-chrome text-decorations

我是CSS的新手,试图了解如何根据状态更改来修改链接。在我的情况下,我想将链接更改text-decoration为“ line-through访问”状态。但是,在MozillaChrome浏览器上,当链接处于“ 访问”状态时,text-decoration文本内容都不会更新,如下所示。我哪里做错了?line-through

请注意,当链接状态更改为已访问但链接text-decoration保持不变时,颜色会更新(变为绿色)(请参阅演示1);

注意:Mozilla有关于同一问题的错误报告:Mozilla错误#645786和错误报告。tag.class:state 选择器(a.:visited)也会出现问题(请参阅演示#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>
Run Code Online (Sandbox Code Playgroud)

演示#2-带类的选择器

<!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)

Lev*_*glu 5

设置访问链接的样式存在限制。

限制访问的链接样式

您仍然可以在视觉上对访问的链接进行样式设置,但是现在可以使用的样式受到限制。只有以下属性可以应用于访问的链接:

color
background-color
border-color (and its sub-properties)
outline-color
The color parts of the fill and stroke properties
Run Code Online (Sandbox Code Playgroud)

隐私和:visited选择器

text-decoration 由于用户的隐私问题,不允许样式设置。

  • 100% 准确,您的回答本可以为我节省很多时间。:) 遗憾的是,Webkit 和 Firefox 的 CSS 检查器将 `:visited` 属性 [除了你提到的那些] 标记为已应用,而在这种情况下却没有。 (2认同)