通过 CSS 设置所有已访问的链接的样式


要设置所有已访问链接的样式,请使用 CSS :visited 选择器。

示例

你可以尝试运行以下代码来实现 :visited 选择器

在线演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         a:link, a:visited {
            background-color: white;
            color: black;
            border: 1px solid blue;
            padding: 30px 30px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
         }
         a:hover, a:active {
            background-color: red;
            color: white;
         }
      </style>
   </head>
   <body>
      <a href = "demo.html" target="_blank">Demo Link</a>
   </body>
</html>

更新日期:2020-07-01

449 次浏览

开启你的 职业生涯

完成课程获得认证

立即开始
广告
© . All rights reserved.