JQuery how to make a smooth transition?
Hy,
i have a div with relative position (CSS) and i want to make it to move on the s开发者_开发技巧creen, changing the left property. This should be a smooth transition from (left: 0px;) to (left: 100px;).
Thanks
You can do this with .animate()
like this:
$("#myDiv").animate({ left: '100px' });
Do the reverse for the opposite animation, and set the initial left position using CSS like this:
#myDiv { left: 0; position: absolute; }
$('#yourDIV').animate({left:'0px',top:'100px'},1000);
where 1000 is your speed
精彩评论