I am trying to create a simple image slider for my web page, and here is the code I came up with jquery css -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title></title> <meta name="" content=""> <script type="text/javascript" src="jquery.js"></script> <style type="text/css"> *{ margin:0; padding:0; } #container{ position:absolute; left:100px; top:100px; width:102px;height:102px; border:1px solid red; overflow:hidden; display:inline; } #container img{float:left;} </style> <script type="text/javascript"> $(document).ready(function(){ setInterval(slideImages, 5000); function slideImages(){ $('#container img:first-child').clone().appendTo('#container'); $('#container img:first-child').remove(); } }); </script> </head> <body> <div id="container"> <img src="1.jpg" /> <img src="2.jpg" /> <img src="3.jpg" /> <img src="4.jpg" /> <img src="5.jpg" /> </div> </body> </html>
While the code is working and displaying the images, I would like to add some more effects to it by adding a new image to the "container" area. Like shifted to the right to the right, and then staying there for a while, and then the next image replaces the existing one in it, again moving from right to left.
Tell me how to get the r-to-l sliding effect. I know I can slide up / down using jquery .. but how to do lr or rl?
Thanks!
source share