Is it possible to animate a change in css using jquery?
If someone would be so kind as to provide me with an example i would be much obliged.
Essentially, i am trying to animate the sprites technique by manipulating the background-image in the css using jQuery. The goal is to animate the hover so that I get a nice fade instead of just the abrupt switch produced by the code below.
Here is where I'm at:
HTML:
<h1 id="solomon">Solomon</h1>
CSS:
body#default h1 {
text-indent: -9999px;
display: inline-block;
height: 213px;
}
body#default h1#solomon {
background: transparent url(/images/S.gif) center top no-repeat;
width: 183px;
margin: 100px 0 0 216px;
}
JQUERY:
$(function() {
$('h1').hover(function() {
$(this).stop().css('background-position', 'center bottom');
}, function() {
$(this).stop().css('background-position', 'center top');
});
});
Right now the it works fine, but there is no pretty animation on hover. I want to know how to animate the effect of switching the background-image placement.
Thanks to whomever takes a shot at this. :)