开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜