...

View Full Version : Change DIV BG Image On Hover



mark87
05-20-2005, 04:45 PM
I'm having trouble changing a DIV background image when it is hovered over - is there an easy way?!

chilipie
05-20-2005, 05:27 PM
div {
background: #hex123 url(back.gif);
}

div:hover {
background-image: url(backhover.gif);
}:)

_Aerospace_Eng_
05-20-2005, 07:32 PM
Okay so ollie gave you the way that would work in any other browser but IE. You might want to use the javascript way to ensure that it will work in IE if of course javascript is enabled.

<div onmouseover="this.style.background='url(yourimage.jpg)';" omouseout="this.style.background='url(youroriginalimg.jpg)';"></div>

EDIT: Sorry I forgot the single quotes, that is why it wasn't working.

mark87
05-20-2005, 09:10 PM
Thanks, but why am I getting an error with -



<div id="startbutton" onmouseover="this.style.background=url(Start_Hover.JPG);" onmouseout="this.style.background=url(Start_Off.JPG);">
</div>


EDIT: No worries - working now!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum