I usually resort to jquery if there is a need to fade in / out of an element.
My HTML will be something like this:
<div id="box"> <div class="box-img"> <img src="image.jpg"/> </div> <div class="box-text"> Lorem ipsum </div> </div>
After that, my CSS will look something like this:
#box{ width:500px; height:500px; padding:0; } .box-img{ position:absolute; opacity:0; } .box-text{ position:absolute; }
And to finish, I will probably use the jquery library for .mouseover () or .hover ():
$("#box").hover( function () { $(".box-img").fadeTo("100,1"); $(".box-text").fadeTo("100,0"); }, function () { $(".box-img").fadeTo("100,0"); $(".box-text").fadeTo("100,1"); } );
This may not be the best method, but I guess the rough idea of โโwhat's possible is somewhere out there.
You can see the .hover () action in the jQuery API . There is a live example in the demo of what looks like what you can search for and uses a different method.
Hope this helps! =)
source share