Sig
Sig

Reputation: 5916

Animating left to right

I'm trying to achieve something that seems quite simple but I have hard time doing so.

How can I animate a div making its width 80% of original from left to right? I want to keep the right margin where it is and moving the left one toward right.

Thanks and have a nice day.

Upvotes: 0

Views: 237

Answers (2)

benesch
benesch

Reputation: 5269

Set float: right on your element. Then:

$("#animate").click(function(){
    $(this).animate({ width: $(this).width() * .8 }); 
});​

jsFiddle

Upvotes: 3

Paul
Paul

Reputation: 9022

primatology was faster, but here's my jsFiddle anyways as it adds some right margin: Demo.

Upvotes: 1

Related Questions