|
|
#1 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Nov 2004
3 posts
Gave thanks: 0
Thanked 0 times
|
CSS rollover effect with two graphics
Hey all,
I'm new to the block. I've had my hosting purchased for about 4 months or so, but just now getting the free time to begin playing. I've created my first site with CSS. It hasn't been difficult so far and I love how the code is rather clean looking. I've got a banner that I want to add a rollover effect to with another image of the exact same dimensions. Here's a snippet of what my index looks like: Code:
<link href="Files/layout.css" rel="stylesheet" type="text/css" /></head> <body> <div id="mBody"> <div id="mHeader"></div> Code:
body
{
background: #000000;
}
#mBody
{
margin: 0 auto;
width: 950px;
border: 1px solid #000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
color:#CCCCCC;
}
#mHeader
{
margin-left: 5px;
margin-right: 5px;
margin-bottom: 10px;
height: 90px;
background:url(Images/90x940Header.gif) no-repeat;
color: #006666;
}
I'm not sure if the way I went about this is good or not, but it works. I've googled and searched these forums for multiple resources concerning this, but none of the examples are exactly like this. Primarily examples of changing the background color or something to keep one single image. Can someone help point me in the right direction on how I can accomplish this? Thanks.a |
|
|
|
|
|
#3 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,092 posts
Gave thanks: 48
Thanked 131 times
|
In most browsers it will require a loading of the second image when you trigger the hover event. It's more practiced to have the images as one file, then change the position of the background to have the second image in view.
|
|
|
|
|
|
#6 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Nov 2004
3 posts
Gave thanks: 0
Thanked 0 times
|
Yeah, write it out!! I'm j/k of course. Thank you for the input. I'll try to figure out how to make it into one image. Is the basic concept that on rollover, the background changes? I'll google more. BTW, the code suggested worked just fine, but I want to try and follow suggested standards if possible. Thanks again.
|
|
|
|
|
|
#7 (permalink) |
|
after g, before i
Resident.
Joined in Jul 2004
Lives in N,BC,CA
8,092 posts
Gave thanks: 48
Thanked 131 times
|
Basically this is it:
Code:
#mHeader {
margin-left: 5px;
margin-right: 5px;
margin-bottom: 10px;
height: 90px;
background:url(Images/90x940Header.gif) 0px 0px no-repeat;
color: #006666;
}
#mHeader:hover {
background-position: -85px 0px;
}
|
|
|
|
|
|
#8 (permalink) |
|
Registered User
Fresh Surpasser
Joined in Nov 2004
3 posts
Gave thanks: 0
Thanked 0 times
|
Thanks for the input. I'm getting my PS friend (I'm horrible with it) to set it up the image for me. The loading of the other img is entirely too obvious of a transition.
You guys are great. |
|
|
|
|
|
#9 (permalink) |
|
Bow before Surpass!
Super #1
Joined in Sep 2004
1,547 posts
Gave thanks: 91
Thanked 49 times
|
I think I found out why my CSS rollovers dont work in all browsers :P Thanks.
__________________
Wii Hotspot - Upcoming project! -http://www.wiihotspot.com
Make a cPanel Login Form | Why is my Account Suspended? |
|
|
|