Log In · Register

 
Help!, Rollover Code Help
dyindyinjohnson
post Jul 22 2009, 03:41 AM
Post #1


Senior Member
***

Group: Official Designer
Posts: 67
Joined: Aug 2008
Member No: 680,736



Okay, I finally got the rollover thing down except I need to move my rollover image somewhere else.
How?



CODE
<style type="text/css">
div, table, tr, td, tbody {background-color:white;}

a.home{
display: block;
height: 50px;
width: 116px;
overflow: hidden;
background-image: url("http://img24.imageshack.us/img24/2995/homexzf.png");
background-position: center;
background-repeat: no-repeat;
}

a.home:hover{
background-image: url("http://img24.imageshack.us/img24/9471/home2w.png");
background-position: center;
background-repeat: no-repeat;
}
</style>


<a href="http://www.google.com/" class="home">
 
 
Start new topic
Replies
Mikeplyts
post Jul 22 2009, 03:18 PM
Post #2


Mel Blanc was allergic to carrots.
*******

Group: Official Designer
Posts: 6,371
Joined: Aug 2008
Member No: 676,291



You could also do the same method that I linked to but just more simpler.



Simply open the image that represents the normal state of the rollover. Now make the canvas size's height twice as high as the original image's height. Make sure your normal state is in the top half. Now paste the image that represents the hover state of the rollover into the bottom half. Save that image and upload it to the web.

Once you have the URL of the image, use this code:
CODE
<style>
a.CLASS_NAME {width:###px; height:###px; background-image: url("URL_OF_SAVED_IMAGE"); background-repeat:no-repeat; background-position:top left;}
a.CLASS_NAME:hover {width:###px; height:###px; background-image: url("URL_OF_SAVED_IMAGE"); background-repeat:no-repeat; background-position:bottom left;}</style>

I assume you know how to replace the fillers and such. One thing though, when you're putting in the value for the height, put half of the height of the saved image since your saved image is double the height of the rollover. We do this because you'll notice for the background position, we have top left as the value before the rollover and bottom left as the value after rollover. Since we inserted half the height, we cut the saved image in two halves and the background position tells the image to display either the top or bottom half.

Now, all you have to do is add your DIV code and your done. (Remember, just repeat the first code for every new rollover.)
CODE
<div style="position:absolute; top:###px; _top:###px; left:50%; _left:50%; margin-left:-###px; _margin-left:-###px;">
<a href="#" class="CLASS_NAME"> <a href="#" class="CLASS_NAME2"> <a href="#" class="CLASS_NAME3">
</div>

Just replace the fillers accordingly.

Hopefully that wasn't too confusing. tongue.gif
 

Posts in this topic
dyindyinjohnsonlayouts   Help!   Jul 22 2009, 03:41 AM
Mikeplyts   Exactly what do you mean? Do you need to position ...   Jul 22 2009, 04:02 AM
dyindyinjohnsonlayouts   Thank you! I was just putting the DIV containe...   Jul 22 2009, 04:04 AM
Mikeplyts   lol, no problem.   Jul 22 2009, 04:05 AM
dyindyinjohnsonlayouts   Okay how do I get the rollovers in one line? (Not ...   Jul 22 2009, 04:37 AM
Mike   Replace your code with this: CODE<style type=...   Jul 22 2009, 05:23 AM
dyindyinjohnsonlayouts   yeah that made them just disappear.   Jul 22 2009, 02:26 PM
theerinkal   ^^ You could've just told him to remove the di...   Jul 22 2009, 05:44 AM
Mikeplyts   Put them all in a separate DIV container. CODE...   Jul 22 2009, 02:37 PM
dyindyinjohnsonlayouts   Well I had them all in one DIV container but putti...   Jul 22 2009, 02:42 PM
Mikeplyts   Ok. There is another code you could use though tha...   Jul 22 2009, 02:46 PM
dyindyinjohnsonlayouts   If you want to, I mean if the code is easier, than...   Jul 22 2009, 02:50 PM
Mike   Try this method.   Jul 22 2009, 02:52 PM
Mikeplyts   ^ What Mike posted can work, or you could also try...   Jul 22 2009, 03:02 PM
dyindyinjohnsonlayouts   ^That one is kinda confusing. XD But with the one ...   Jul 22 2009, 03:07 PM
Mikeplyts   You could also do the same method that I linked to...   Jul 22 2009, 03:18 PM
dyindyinjohnsonlayouts   Filters as in the class name?   Jul 22 2009, 03:20 PM
Mikeplyts   Yep. Along with the pound signs and all that mumbo...   Jul 22 2009, 03:21 PM
dyindyinjohnsonlayouts   Haha. Okay. And for the images it would look like ...   Jul 22 2009, 03:25 PM
Mikeplyts   Correct.   Jul 22 2009, 03:58 PM
Mikeplyts   ^Or that. haha. I didn't even see his code...   Jul 22 2009, 04:36 PM
dyindyinjohnsonlayouts   I'm just going to use my old code, and us sepe...   Jul 22 2009, 04:54 PM
fixtatik   Float, float, float. Whenever you have something...   Jul 22 2009, 04:59 PM
dyindyinjohnsonlayouts   ^ Thanks. Works, much easier than having like 6 Di...   Jul 22 2009, 05:27 PM
Mike   Posts merged.   Jul 22 2009, 05:37 PM
alek   or you could always add positioning elements to th...   Jul 26 2009, 07:23 PM


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: