[英]Animate width left to right
I am trying to find a way to animate a div using jQuery to shrink the width from left to right. 我试图找到一种方法来使用jQuery的div动画以将宽度从左向右缩小。
I have the element on click at first: 我首先要点击一下元素:
Any ideas? 有任何想法吗?
Shrink it right to left (like you know how to), but simultaneously increase the left position style, or the left margin. 将其从右向左缩小(如您所知),但同时增加左位置样式或左边界。
Something like: 就像是:
var distance = $("div").css("width");
$("div").animate({
"width": "0",
"marginLeft": distance
});
you need to set the margin property. 您需要设置margin属性。 But you'll also want to position it absolutely if there's any elements either side of it.
但是,如果它的两侧都有任何元素,则也要绝对定位它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.