I am trying to find a way to animate a div using jQuery to shrink the width from left to right.
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. But you'll also want to position it absolutely if there's any elements either side of it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.