Html / css sprite nav works fine for me. When each link in the unordered list hangs, the background image of the sprite changes as expected for this particular element
. I want to make the move position of the entire navigation sprite based on the fact that the linked one freezes, so that the effect for any one link changes the background for the entire unordered list.Reason: the edges of each embedded
are not vertical, they have an angle of 45 degrees, so changing the traditional background of the background does not work so well. Changing the whole background will be perfect.Used code:
CSS
#nav {
position: relative;
float: right;
background: url('../gfx/nav.gif');
width: 498px;
height: 23px;
margin: 110px 2px 0 0;
border: 0;
padding: 0;
}
#nav li {
position: absolute;
top: 0;
margin: 0;
border: 0;
padding: 0;
list-style: none;
}
#nav li, #nav a {
height: 23px;
display: block;
}
#nav span {
display: none;
}
#n1 {
left: 0;
width: 73px;
}
#n2 {
left: 74px;
width: 94px;
}
#n3 {
left: 167px;
width: 124px;
}
#n4 {
left: 292px;
width: 82px;
}
#n5 {
left: 375px;
width: 125px;
}
#n1 a:hover {
background: transparent url('../gfx/nav.gif') 0 -23px no-repeat;
}
#n2 a:hover {
background: transparent url('../gfx/nav.gif') -74px -46px no-repeat;
}
#n3 a:hover {
background: transparent url('../gfx/nav.gif') -167px -69px no-repeat;
}
#n4 a:hover {
background: transparent url('../gfx/nav.gif') -292px -92px no-repeat;
}
#n5 a:hover {
background: transparent url('../gfx/nav.gif') -375px -115px no-repeat;
}
And HTML:
<ul id="nav">
<li id="n1"><a href="./"><span>Home</span></a></li>
<li id="n2"><a href="./?c=about"><span>About</span></a></li>
<li id="n3"><a href="./?c=programmes"><span>Programmes</span></a></li>
<li id="n4"><a href="./?c=grants"><span>Grants</span></a></li>
<li id="n5"><a href="./?c=publications"><span>Publications</span></a></li>
</ul>
, , , ? , JS .
.:)
PS - jsfiddle - http://jsfiddle.net/NhL7E/
, , UL, LI.
Shive, Jcubed Barry Dowd. , . - - HTML/CSS , , .
, , . , , . , . - HTTP- jQuery, JS/jQuery... ..
- , jsfiddles, ... !
Cas