概述
Is there any way i can animate a div using percentages with jquery?
I've tried these:
$('.box1').animate({width:($(".wrapper").width()*.100)},"fast");})
$('.box1').animate({width:'100%'},"fast");})
$('.box1').animate({width:100%;})
none of the above work...
any ideas?
UPDATE
var p_e_h= 1.0;
var p_e_w= 1.0;
$('.box1').animate({width:($(".wrapper").width()* p_e_w)},"fast");
$('.box1').animate({height:($(".wrapper").height()* p_e_h)},"fast");
width works, but height does not. Unless i click the button again.
解决方案var fiftyPrct = 0.5, //50%
hundredPrct = 1; //100%
$('.box1').animate({ width: ($('.wrapper').width() * fiftyPrct) }, 'fast');
$('.box2').animate({ width: ($('.wrapper').width() * hundredPrct) }, 'fast');
Should work fine.
Update
Since you are doing 2 different .animate calls, the animations are queued and executed sequentially. Just do them with the same animation call:
var p_e_h= 1.0;
var p_e_w= 1.0;
$('.box1').animate({
width: ($(".wrapper").width() * p_e_w),
height:($(".wrapper").height() * p_e_h)
},"fast");
Example of it working: jsFiddle
最后
以上就是阳光奇异果为你收集整理的ege动画,jquery使用percenteges进行动画制作的全部内容,希望文章能够帮你解决ege动画,jquery使用percenteges进行动画制作所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复