How do I make an image mouseover with CSS?

3

Posted by Louis | Posted in Web Design Tutorials | Posted on 30-10-2009

Tags: , , ,

I’m trying to make a mouseover for my myspace site. Myspace does not support javascript but does support html and css. I’m very new so I need a really detailed explaination. if anyone can help me, I’d be soooo grateful! thanks!

Comments (3)

by using background-image. However, in IE this causes a flicker because IE does not cache background images (why? argh).

Heres an example: http://www.domedia.org/oveklykken/cs…over-image.php

<img src="off.jpg" onmouseover="this.src=’on.jpg’ "
onmouseout="this.src=’off.jpg’ ">

Remove the spaces.

<style type="text/css">
.yourclass {
background-image: url(image_off.png);
width: 80px;
height: 20px;
}
.yourclass:hover {
background-image: url(image_on.png);
width: 80px;
height: 20px;
}
</style>

<a class="yourclass" href="…">text or  </a>

The secret is in the :hover selector, which acts when the mouse is over the link.

Write a comment

Powered by Yahoo! Answers