css链接访问过的背景

时间:2015-11-26 17:28:34

标签: css hyperlink background visited

由于某种原因,访问过的背景没有变为灰色。 任何人都知道如何解决?

a:link {
  height: auto;
  display: inline-block;
  border-radius: 5px;
  background: rgb(241,231,103);
  background: linear-gradient(to bottom, rgb(241,231,103) 0%, rgb(241,231,103) 32%, rgb(248,217,54) 73%, rgb(253,208,22) 100%);
}

a:visited {
  background-color: gray;
}

a:hover {
  background: linear-gradient(to bottom, rgb(253,208,22) 0%, rgb(248,217,54) 27%, rgb(241,231,103) 68%, rgb(241,231,103) 100%);
}

HTML文件,我需要在我的任务中使用css

<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>

<a href="http://www.stackoverflow.com">one</a>
<a href="#">two</a>
<a href="#">three</a>
<a href="#">seven</a>

</body>

3 个答案:

答案 0 :(得分:1)

尝试为链接设置默认背景颜色,例如white

a{
  background-color: white;
}

然后

a:visited {
  background-color: gray;
}

答案 1 :(得分:0)

a:visited不是完全证明这样做的方法。你可以用一个简短的jquery来制作它。

<强>的jQuery

$('a').click(function(){
    $('a').css('background-color','gray')
})

以上方法非常适合您的问题:)

答案 2 :(得分:0)

a:link {
  height: auto;
  display: inline-block;
  border-radius: 5px;
  background: red;
}

使用此

相关问题