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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing images with CSS

Status
Not open for further replies.

sfenx

Programmer
Feb 23, 2001
81
BE
Hi,
I wondered if it's possible to change an image captured in an Anchor by another image using CSS a:hover ?
for example when I hover this link :
<A href=&quot;...&quot;><img scr=&quot;image1.gif&quot;></a>
then display image : &quot;image2.gif&quot;

Thkx,
Sfenx
 
You can do that easily with JavaScript. Change only on MouseOver:
<A href=&quot;...&quot;><img scr=&quot;image1.gif&quot; onMouseOver=&quot;this.src='image2.gif';&quot;></a>
Change onMouseOver and onMouseOut:
<A href=&quot;...&quot;><img scr=&quot;image1.gif&quot; onMouseOver=&quot;this.src='image2.gif';&quot; onMouseOut=&quot;this.src='image1.gif';&quot;></a>

I'm not sure if it's possible in CSS. I think it is, but everyone uses JavaScript for this, so I'm giving you this version.

Rick -----------------------------------------------------------
RISTMO Designs
Arab Church
 
Maybe this will work:

------CSS------

<style type=&quot;text/css&quot;>
a.flip:link span.on { display: block; }
a.flip:link span.off { display: none; }
a.flip:hover span.on { display: none; }
a.flip:hover span.off { display: block; }
</style>

------HTML------

<a href=&quot;...&quot; class=&quot;flip&quot;>
<span class=&quot;off&quot;><img src=&quot;img1.gif&quot;></span>
<span class=&quot;on&quot;><img src=&quot;img2.gif&quot;></span>
</a>

petey
 
You could use the onmouseover /onmouseoff events to change the CSS class. Each class could specify a background image for a div or span which you should probably specify dimensions for.
Just an idea...


É ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top