Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使当前页面与其他链接不同_Html_Css - Fatal编程技术网

Html 如何使当前页面与其他链接不同

Html 如何使当前页面与其他链接不同,html,css,Html,Css,我希望当前页面的颜色为绿色背景 这是我的密码 我的css a.current:active{background:green;} 现在。我的html <a class="current" href="/">Home</a> / <a class="current" href="about">About</a> / <a class="current" href="contact">Contact</a> / /

我希望当前页面的颜色为绿色背景 这是我的密码

我的css

a.current:active{background:green;} 
现在。我的html

<a class="current" href="/">Home</a> / 
<a class="current" href="about">About</a> / 
<a class="current" href="contact">Contact</a>
/
/ 
但是它不能在pls上帮助我。

“主动选择器用于选择和设置主动链接的样式

当您单击链接时,它将变为活动链接。“

你应该做的不是对所有链接使用“current”类,而是对当前页面这样使用它

 <a class="current" href="/">Home</a> / <a href="about">About</a> / <a href="contact">Contact</a>
a.current {
     background: green;
}

使用“current”类作为当前页面链接。

请详细说明,如果您能创建一个演示,演示您正在尝试实现的内容,那会更好。您可以使用remove:active from a.current:active{background:green;}将
display:inline块添加到css@Oyekinle很好,但是我怎么才能知道我们在那个页面上,所以我将使用php添加
Home
我想我需要javascript代码来帮助我呢