• 0

images a:hover


Question

i resize some images on my blog to fit the theme, so i have decided to make a dark, transparent overlay on the image that says "click to enlarge" whenever the mouse hovers over the image

i have the png for the overlay ready, but im not sure how you would code that in css,

and all my images are under the class ".postimage"

so i was thinking something about .postimage a:hover?

thanks!

Link to comment
https://www.neowin.net/forum/topic/713204-images-ahover/
Share on other sites

7 answers to this question

Recommended Posts

  • 0

My guess since it is a class and assuming it is under an id "main" (I never used word press so I'm just making up a random id) and if the class is part of an img. I would say try "#main img..portimage:hover". That extra dot in front of portimage just makes it look odd. Or you could try, "img..portimage:hover".

Link to comment
https://www.neowin.net/forum/topic/713204-images-ahover/#findComment-590319036
Share on other sites

  • 0

First :hover will work only for a in IE6. In other browsers including ie7 it works for all elements. The best way to do what you are after is to enclose the image and a span for the overlay inside a as show below.

<a class="gallery" href=""><span class="overlay"></span><img src="" /></a>

The css...

a.gallery, a.gallery:visited {
width: (width of image);
height: (height of image);
display: block;
position: relative;
}
a.gallery, a.gallery:visited img {
display: block;
}
span.overlay {
top: 0;
left: 0;
height: (height of overlay image);
width: (width of overlay image);
display: block;
position: absolute;
margin-left: -9000px;
background: (set overlay image as background);
}
a.gallery:hover span.overlay {
margin: 0;
}

Link to comment
https://www.neowin.net/forum/topic/713204-images-ahover/#findComment-590333376
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.