Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Background image position switching for navigation bar

Status
Not open for further replies.

qtluvsjc

Technical User
Apr 27, 2007
18
US
I am trying to create a rollover effect using css. I have my background images set up (left side and right side), and they are 672px high. the top 336 px are the static background, and the bottom 336 px is the rollover background.

For some reason when i roll over the link, the image that is supposed to be on the left goes to the right, and the image that is supposed to be on the right goes to the left. here is the css for my navigation.. can anyone help? Thanks!

#navigation {
background: #F4FAFA;
border-width: 1px 0;
font-size: .9em;
font-family: Arial, Helvetica, sans-serif;
}

#navigation ul, #navigation ul li {
list-style: none;
margin: 0;
padding: 0;
}

#navigation ul {
padding: 5px 0;
text-align: center;
}

#navigation ul li {
display: inline;
margin-right: 5px;
}

#navigation ul li.last {
margin-right: 0;
}

#navigation ul li a {
background: url("../tab-right.gif") no-repeat right top;
color: #004B4C;
padding: 5px 0;
text-decoration: none;
}

#navigation ul li a span {
background: url("../tab-left.gif") no-repeat left top;
padding: 5px 1em;
}

#navigation ul li a:hover span {
color: #004B4C;
text-decoration: none;
}


#navigation a:hover {
background-position:0% -336px;
}
#navigation a:hover span {
background-position:100% -336px;
}
 
On hover, you seem to move the background on anchor element from right (... right top) to left (... 0% -336px) and on span element vice versa, from left (... left top) to right (100% -336px). This is most likely what is causing your problem. Try to switch those values and see if it helps.

If not, we would have to see the page in question (or at least the gif files).

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top