Help - Search - Members - Calendar
Full Version: changing the border around an image on mouseover
Movable Type Community Forum > Additional Resources > Tips and Tricks
bchaplin
I just posted a page of photos (part of the 26 things project), and would like to set up the images as links to larger photos.

Is there a way to make the borders around the images change color when the user mouses over them (using CSS, not Javascript)?

The HTML code would look like this:

CODE
<a href="xxx.html">
  <img class="photo" src="smallImages/IMG_2171.JPG" width="400" height="300">
</a>


and the applicable parts of the stylesheet like this:

CODE
.photo {border: 2px solid #fff;}
Lummox JR
You should be able to change the border color this way:
CODE
a:hover .photo {border-color: #eee}

In theory I think just .photo:hover is supposed to work, but I think IE doesn't recognize :hover on anything besides a link.

Lummox JR
Lela
I think you've stumbled across one of those IE bugs ...

You could try the code discussed in This Forum. This at least appears to be supported by IE (although I question its versatility).
kadyellebee
This looks nice in Phoenix:
CODE
.photo a:hover, .photo:hover {border: solid 2px black;}

I don't know if older versions of IE will do anything with this, but it seems like it should work in IE6 at least. .photo a:hover seems to work better than a:hover .photo in my previous experience.

Kristine
bchaplin
I looked at the discussion on the forum that Lela pointed to, but as it turned out, Lummox's code worked in both IE and Safari (on a Mac). Good enough for me! Thanks for the help.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.