Vignesh Pichamani
Vignesh Pichamani

Reputation: 8070

Slide div Move Left to right, right to left and after it is in center using jquery

I created the div with class of font-style within this contain message. for example:

<div class="font-style" style=position:relative>
Hi all How are you !!!
</div>

And the Jquery is

   jQuery('.font-style').css({'right': '0px', 'left': '300px'}).animate({
                                    'right': '300px'
                                });
                                jQuery('.font-style').css({'right': '300px', 'left': '0px'}).animate({
                                    'left': '300px'
                                });

On Load it appear center and after it moves from right to left and after that left to right. It working perfect but my question is how to make it as center after it move from left to right.

Demo

Upvotes: 1

Views: 3399

Answers (2)

S. S. Rawat
S. S. Rawat

Reputation: 6111

Try this Demo Here, This is more helpful for you

Upvotes: 1

user2587132
user2587132

Reputation:

  jQuery('.font-style').animate({
  'right': '300px'
  },'slow').animate({
  'left': '300px'
  },'slow').animate({
  'left': '0',
  'right': '0'
  });


<div style="width:100%" id="p">
<div class="font-style" style=position:relative>Hi all How are you !!!</div>
</div>


#p{text-align:center;}
font-style{
}

http://jsfiddle.net/LRSbZ/

Upvotes: 3

Related Questions