Link to home
Start Free TrialLog in
Avatar of Eric Bourland
Eric BourlandFlag for United States of America

asked on

Need help getting CSS sprite rollover to work

Hello, experts. I've been staring at this problem for several days now. (I'm stubborn.) I am trying to get a sprite rollover to work on this page:

http://thethirdindustrialrevolution.com/test/TIR_rollovers.html

When you mouse over the Home image, the image should be replaced with another, blue version of the image.

The background image is located here: http://thethirdindustrialrevolution.com/test/header.png

The goal, in the end, will be to set up all of the rollover images displayed in the header.png file, above.

Thank you for any advice.

Eric
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TIR Sprite Setup</title>
<!--<link rel="stylesheet" type="text/css" media="screen" href="nav.css" />-->
<style type="text/css">

html	{
margin:0;
}

body {
	margin:0 auto;
	padding:0;
	}

/* Navigation
----------------- */

#navlist {   position:relative;/* background: transparent url(header.png) no-repeat;*/ width:1008px; height:390px; margin:0 auto; padding:0;
}

#navlist li {   padding:0;list-style:none;position:absolute;top:180px; left:70px;   }

#navlist li, #navlist a {     height:94px;display:block;   }

#navHome        a {width:93px; height:94px;}

#navHome a:link, #navHome a:visited    {background: transparent url('http://thethirdindustrialrevolution.com/test/header.png') -70px -180px;}

#navHome a:hover, #navHome a:focus    {background: url('http://thethirdindustrialrevolution.com/test/header.png') -70px -394px;}

</style>


</head>

<body>

<ul id="navlist">
    <li id="navHome"><a href="http://thethirdindustrialrevolution.com/"></a></li>
    <li id="navAuthor"><a href="http://thethirdindustrialrevolution.com/pages/About-Jeremy-Rifkin.cfm"></a></li>
    <li id="navPress"><a href="http://thethirdindustrialrevolution.com/press.cfm"></a></li>
    <li id="navBlog"><a href="http://thethirdindustrialrevolution.com/blog.cfm"></a></li>
</ul>

</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gregg
Gregg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please add text links to your navigation.

<style type="text/css">
#navlist a {
	text-indent: -9999px;
}
</style>


<li id="navHome"><a href="yourWebsite.com">Home</a></li>

Open in new window

Avatar of Eric Bourland

ASKER

Gregg, thank you, I will try this now.

Eric
Gregg, thank you. This worked for the lower navigation links: Home, Author, Press, Blog. You can see it here:

http://thethirdindustrialrevolution.com/test/TIR_rollovers.html

Now I need to figure out a way to add CSS sprite rollovers for the top three navigation menu items: Facebook, Twitter, YouTube; and for the "Buy The Book" image. I might ask another question to get help with that.

Thank you again. Have a great evening.

Eric
Good job!

I would think its the same concept. Do you have the rollover graphics created for the next section?
Scratch last comment. I see them now in updated page.
Gregg,

Yep, I will apply the same concept. All of the graphics for all rollover items are located in one PNG image: http://thethirdindustrialrevolution.com/test/header.png

I am working first on the "social media" rollovers.

Thanks again for your help. Take care.

Eric
Awesome! Thats a great trick to implement. :-D
You should be able to use a relative path in the image source. I used full url to see it locally.

background: url(images/header.png)
background: url(header.png)

Hover images are perfect, good job.