如何制作“动画”使用 jquery 运行相反的方向
这是我的代码:
$('#map_canvas').animate({width:'69.8%'},300);
这将从左到右运行,
如何使其从右到左运行?
谢谢
this is my code:
$('#map_canvas').animate({width:'69.8%'},300);
this will run from left to right ,
how to make it from right to left ?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以这样做:
你可以在这里尝试一下,我放慢了速度10 倍以更好地看到效果。我们所做的就是计算元素的宽度 * 30.2%,以查看它应该向左移动多远,并同时为该属性设置动画。所有元素需要至少是
position:relative
才能正常工作。上面的代码应该适用于所有情况,但这个更简单的版本也适用于大多数情况:
You could do something like this:
You can give it a try here, I slowed it down 10x to better see the effect. All we're doing is calculating the width of the element * 30.2% to see how far left it should move and animating that property at the same time. All the element needs is to be at least
position: relative
for this to work.The above should work in all cases, but this simpler version will work in most cases as well:
要将其从右向左滑回,请再次将其宽度设置为 0:
To slide it back from right to left, make its width 0 again: