2015-11-26 54 views
0

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

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> 
+1

你能提供一些HTML呢? – CoderPi

+0

尝试设置你的链接的默认'背景color',检查答案 –

+0

<!DOCTYPE HTML> <链接相对= “样式的” href = “CSS/style.css文件”>

Darius

回答

0

a:visited是不是做这充分证明方式。你可以用一个简短的jQuery来做到这一点。

jQuery的

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

上述方法适合您的问题:)

+0

我需要在我的任务仍然 – Darius

1

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

a{ 
    background-color: white; 
} 

然后

a:visited { 
    background-color: gray; 
} 
+0

用css没有工作 – Darius

+0

它可以正常使用的兄弟 –

+0

完全符合backgr工程ound设置为简单颜色,但我们需要为与上面完全相同的背景设置渐变,然后将访问集链接为灰色。 – Darius

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

使用本

+2

请添加一些解释,而不是只订购OP'使用这个' –

+0

以上代码您将定义一个背景,然后'a:visited'也将工作,而不先定义背景,它不会采用'a:visited'也 –

+0

完美地将背景设置为简单的颜色,但我们需要为与上面完全相同的背景设置渐变,然后将访问集链接到灰色。 – Darius