I have a working fade in/fade out jQuery example here: http://jsfiddle.net/mcgarriers/NJe63/6/
However, I'm wondering if it is possible to replace the background-color red effect with a background image?
Many thanks for any pointers
I have a working fade in/fade out jQuery example here: http://jsfiddle.net/mcgarriers/NJe63/6/
However, I'm wondering if it is possible to replace the background-color red effect with a background image?
Many thanks for any pointers
You could do this with CSS3. You could create a div tag to the size of your choice around the image then use a basic CSS3 transition.
#yourdiv a {
background-color: #FFF;
}
#yourdiv a:hover {
background-color: #000;
-webkit-transition: background-color 600ms linear;
-moz-transition: background-color 600ms linear;
-o-transition: background-color 600ms linear;
-ms-transition: background-color 600ms linear;
transition: background-color 600ms linear;
}
Or you can have a image fade into another with CSS3:
http://css3.bradshawenterprises.com/cfimg1/
How about trying something like this?
I altered the code from your jsfiddle link.
$('.box').mouseenter(function(){
$(this).stop().animate({opacity: 0}, 0).css('background', 'url(http://static.tvtropes.org/pmwiki/pub/images/Hello_Kitty_Pink_2981.jpg)').animate({ opacity: 1 }, 1000);
}).mouseleave(function(){
$(this).stop().animate({opacity: 1}, 0).css('background', 'white');
});
You cannot fadein/fadeout background-image of a HTML element, but you can with background-color.
Would it possibly be your solution? Fade background image in and out with jQuery?