开发者

JQuery how to make a smooth transition?

开发者 https://www.devze.com 2022-12-27 16:25 出处:网络
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.

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

精彩评论

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