Width animation from left to right

I am trying to find a way to animate a div using jQuery to shrink the width from left to right.

I have an element when clicked first:

  • move from left to right
  • then it will continue right after my div as if it was just moving off the page, enters and clicked again. I have a toggle function and is working correctly, but I'm not sure how to get it to keep navigating from the page.

Any ideas?

+2


source to share


2 answers


you need to set the margin property. But you will also want to install it absolutely if there are any elements from its side.



+3


source


Shorten this from right to left (as you know how), but at the same time increase the style of the left position or left margin.

Something like:



var distance = $("div").css("width");

$("div").animate({
"width": "0",
"marginLeft": distance
});

      

+4


source







All Articles