admin管理员组文章数量:1390503
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.
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.
Share Improve this question edited Nov 28, 2011 at 17:34 asked Nov 28, 2011 at 17:13 user849137user849137 2-
1
width: 100%;
would be treated as trying to take the modulo of 100 using a semicolon as the divisor - a syntax error. – Marc B Commented Nov 28, 2011 at 17:16 -
6
*.100
is not really 100%. – pimvdb Commented Nov 28, 2011 at 17:17
1 Answer
Reset to default 6var 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
本文标签: javascriptjquery animate with percentegesStack Overflow
版权声明:本文标题:javascript - jquery animate with percenteges - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744699802a2620498.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论