Advertisement
jiue123

slide image from right to left

Aug 28th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.13 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title></title>
  5. <meta name="" content="">
  6. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  7. <style type="text/css">
  8.     #container{
  9.     overflow:hidden;
  10.     width:180px;
  11.     height:100px;
  12.     }
  13.     #slide{
  14.     width:550px;
  15.     display:block;
  16.     }
  17.     #slide > img{
  18.     display:inline;
  19.     width:180px;
  20.     height:100px;
  21.     }
  22. </style>
  23. <script type="text/javascript">
  24.     $(document).ready(function(){
  25.         var slide = function(){ $('#slide').animate({
  26.             marginLeft : parseInt($('#slide').css("margin-left"))-180 + "px"                       
  27.             },2000,"swing",
  28.             function(){
  29.             $("#slide").css("margin-left","0px");
  30.             $("#slide img:first").appendTo("#slide");
  31.             });
  32.         };
  33.         setInterval(slide,7000);   
  34.     });
  35. </script>
  36. </head>
  37. <body>
  38.     <div id="container" style="margin-left:0">
  39.         <div id="slide">
  40.             <img src="http://s2.postimg.org/5uxqi0mgl/cats1.jpg" />
  41.             <img src="http://s2.postimg.org/66f6us2wl/cats2.jpg" />
  42.             <img src="http://s2.postimg.org/ai3sjs9th/cats3.jpg" />
  43.         </div>
  44.     </div>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement