I am trying to make an image animate and make it larger. I have gotten it to change size but I am now trying to make it so none of the surrounding elements don’t get moved around as well. I am using jQuery to do the animations and for some reason it wont increment the margin’s every step. It only does it after it has finished. I thought I read the jQuery docs correctly. Here is my code so far:
$(document).ready(function(){
$(".image").mouseenter(function(){
$(this).animate({height: "176px", width: "250px"},
{
step: function(now, fx) {
$(this).css("margin-left","-=0.076");
$(this).css("margin-right","-=0.084");
$(this).css("margin-bottom","-=0.152");
}
});
});
$(".image").mouseleave(function(){
$(this).animate({height: "100px", width: "174px"},
{
step: function(now, fx) {
$(this).css("margin-left","+=0.076");
$(this).css("margin-right","+=0.084");
$(this).css("margin-bottom","+=0.152");
}
});
});
});
Try CSS3 animations:
The above will scale the image on hover.