当用户在相应页面中时,我想将悬停设置为活动状态。例如,当用户在 HOME 中时,它会使悬停处于活动状态。默认图标为白色,在相应页面中将变为绿色。
这是我来自 jsfiddle http://jsfiddle.net/kQNHj/的原始来源
这是我的基本 html 源代码
<div class="submenu">
<div class="submenu-img" >
<a href="#"><div class="icon-home"></div></a>
<a href="#"><div class="icon-groups"></div></a>
<a href="#"><div class="icon-members"></div></a>
</div>
</div>
这是我的CSS
.submenu {
background-color: #353535;
overflow: hidden;
position: relative;
}
.submenu-img {
float: left;
position: relative;
padding: 30px 0 30px 0;
margin-left: 35%;
}
/*--------------------------------------------------------------
Submenu "Home" icon
--------------------------------------------------------------*/
.submenu-img .icon-home {
background-image: url(http://imageshack.us/a/img607/9549/j3oe.png);
background-repeat: no-repeat;
display: block;
position: relative;
height: 56px;
width: 41px;
margin: 0 55px 0 0;
float:left;
}
.submenu-img .icon-home:hover {
background-image: url(http://imageshack.us/a/img202/4181/nlnf.png);
}
.submenu-img .icon-home:active {
background-image: url(http://imageshack.us/a/img607/9549/j3oe.png);
}
/*--------------------------------------------------------------
Submenu "Groups" icon
--------------------------------------------------------------*/
.submenu-img .icon-groups {
background-image: url(http://imageshack.us/a/img191/1220/9sb7.png);
background-repeat: no-repeat;
display: block;
position: relative;
height: 54px;
width: 49px;
margin: 0 55px 0 0;
float: left;
}
.submenu-img .icon-groups:hover {
background-image: url(http://imageshack.us/a/img818/6343/3vhv.png);
}
.submenu-img .icon-groups:active {
background-image: url(http://imageshack.us/a/img191/1220/9sb7.png);
}
/*--------------------------------------------------------------
Submenu "Members" icon
--------------------------------------------------------------*/
.submenu-img .icon-members {
background-image: url(http://imageshack.us/a/img62/4964/6spa.png);
background-repeat: no-repeat;
display: block;
position: relative;
height: 54px;
width: 64px;
margin: 0 55px 0 0;
float: left;
}
.submenu-img .icon-members:hover {
background-image: url(http://imageshack.us/a/img842/6206/reko.png);
}
.submenu-img .icon-members:active {
background-image: url(http://imageshack.us/a/img62/4964/6spa.png);
}