在 CSS 中,访问过的链接不会改变颜色

use*_*026 4 html css

我是新手学习网络开发。以下是我的test.html文件和test.css以下代码段中的文件。

现在,我有最新的 Mozilla firefox (66.0.5) 和 Chrome (74.0.3729.131) 浏览器。我在 Firefox 中设置永远不会记住历史。但是 Chrome 具有记住历史的设置。当我打开时test.html,链接颜色在 Firefox 中显示为红色,在 Chrome 中显示为蓝色。单击链接不会改变这些浏览器中的颜色。那么这种行为的原因是什么,我如何让链接只有在点击后才变成蓝色?

 /* give red color to web link  */

 a {
   color: red ;
 }

 /* give blue color to the link after its
 visited */

 a:visited {
   color: blue ;
 }
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="test.css">
  </head>
  <body>

    <a href="http://www.google.com">Go to Google !</a>

  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

Rac*_*len 5

不要使用a:visited,而是使用a:focus`。

它被证明对我来说更可靠,因为当链接获得焦点时颜色会发生变化,访问似乎不可靠,因为缓存访问会影响它..boo

希望这可以帮助