更改所选链接的 BG 颜色 [英] Changing the BG Color of a selected link

查看:30
本文介绍了更改所选链接的 BG 颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在使用的菜单,当我使用 a:hover 悬停时,它会更改背景颜色,但我想知道如何更改 class=line> 这样它就粘住了.

I have a menu that I am using and it will change the background color when I hover using a:hover but I want to know how to change the class=line so that it sticks.

所以从主页如果他们点击联系主页

So from the home if they click contacts the home pages

从 (a href="#" class="clr") 到 (a href="#")

from (a href="#" class="clr") to (a href="#")

和联系人会改变

从 (a href="#") 到 (a href="#" class="clr")

from (a href="#") to (a href="#" class="clr")

有什么帮助吗?

京东

推荐答案

我相信您希望突出显示您所在的导航项.我的答案这里是在这个问题上也相当有效,我相信:

I believe you are wanting to highlight the navigational item that you're on. My answer here is fairly valid in this question as well, I believe:

这是一个更好的语义匹配,并且可能是一个更容易设置的变量,以在任何地方使用相同的类或 id 保持导航,并且只更改 body 元素的 id 以匹配:

It's a better semantic match and likely an easier variable to set to keep the navigation using the same classes or ids everywhere and only alter the body element's id to match:

<li id="homeNav">home</li>
<li id="blogNav">blog</li>

然后在每一页...

<body id="home">
<body id="blog">

在 css 中:

#home #homeNav {background-image:url(homeNav-on.jpg);}
#blog #blogNav {background-image:url(blogNav-on.jpg);}

这篇关于更改所选链接的 BG 颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆