on hover overlay image in CSS

Posted by Juventus on Stack Overflow See other posts from Stack Overflow or by Juventus
Published on 2010-03-19T00:08:05Z Indexed on 2010/03/19 0:11 UTC
Read the original article Hit count: 787

Filed under:
|
|
|

I need a div with picture bg to overlay an image (with some amount transparency) when hovered on. I need to be able to have one transparent overlay that can be used and reused throughout the site on any image. My first attempt was round-about to say the least. Because I found out you cannot roll-over an invisible div I devised a sandwhich system in which the original image is the first layer, the overlay is the second layer, and the original image is third layer again. This way, when you roll-over, the original image disappears revealing the overlay image over the original image:

http://www.nightlylabs.com/uploads/test.html

So it works. Kinda. Because of you cannot interact with an visibility:invisible element (why?!) the roll-over flickers unless you rest the cursor on it.

Any help? This method is bad so if anyone has a better one please comment.

© Stack Overflow or respective owner

Related posts about css

Related posts about overlay