Forum Moderators: not2easy

Message Too Old, No Replies

CSS Sprite Rollover (Current Page) Problems

         

truweb

3:11 pm on Oct 12, 2009 (gmt 0)

10+ Year Member



Im still learning and im having trouble grasping this...

I have an image sprite that i use for a horizontal navigation menu. I have no problems using the following code to get a hover working but i have no clue how to implement having the "current" page as the same color as the "hover" state.

Heres my code.

HTML

<ul id="topheader">
<li id="topheader01"><a href="#"><span>Home</span></a></li>
<li id="topheader02"><a href="#"><span>Home</span></a></li>
<li id="topheader03"><a href="#"><span>Portfolio</span></a></li>
<li id="topheader04"><a href="#"><span>Pricing</span></a></li>
<li id="topheader05"><a href="#"><span>Contact</span></a></li>
</ul>

CSS

#topheader {
background : url(../images/truheader.gif) no-repeat;
width : 900px;
height : 129px;
top : 0;
padding : 0 0;
}
#topheader span {
display : none;
}
#topheader li, #topheader a {
height : 129px;
display : block;
}
#topheader li {
float : left;
list-style : none;
display : inline;
}
#topheader01 {
width : 466px;
}
#topheader02 {
width : 97px;
}
#topheader03 {
width : 116px;
}
#topheader04 {
width : 97px;
}
#topheader05 {
width : 105px;
}
#topheader01 a:hover {
background : url(../images/truheader.gif) no-repeat 0 -129px;
}
#topheader02 a:hover {
background : url(../images/truheader.gif) no-repeat -466px -129px;
}
#topheader03 a:hover {
background : url(../images/truheader.gif) no-repeat -563px -129px;
}
#topheader04 a:hover {
background : url(../images/truheader.gif) no-repeat -679px -129px;
}
#topheader05 a:hover {
background : url(../images/truheader.gif) no-repeat -776px -129px;
}

What do i need based on my code to get the current page to be highlighted with the same positioning as the hover? Any help is greatly appreciated.

swa66

11:49 pm on Oct 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How do you plan to know which is the to be highlighted tab ?
e.g.:
- adding a class on the appropriate tab ?
- or adding a class on a wrapper/body/... to point to where you are ?

truweb

12:58 am on Oct 13, 2009 (gmt 0)

10+ Year Member



Thanks for the reply, i figured it out. I had some misplaced HTML. I added a class on a wrapper.