Advertisement
firoze

add background moving image animation

Oct 23rd, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. // add background moving image animation
  2.  
  3. <div class="admin_area"></div> call this into body tag
  4.  
  5. *****************************************************************************
  6. call this into head tag
  7.  
  8. <script type="text/javascript">
  9. // speed in milliseconds
  10. var scrollSpeed = 70;
  11. // set the default position
  12. var current = 0;
  13. // set the direction
  14. var direction = 'h';
  15. function bgscroll(){
  16. // 1 pixel row at a time
  17. current -= 1;
  18. // move the background with backgrond-position css properties
  19. $('div.admin_area').css("backgroundPosition", (direction == 'h') ? current+"px 0" : "0 " + current+"px");
  20. }
  21. //Calls the scrolling function repeatedly
  22. setInterval("bgscroll()", scrollSpeed);
  23. </script>
  24. <style type="text/css">
  25. .admin_area {background:#3e83c8 url(http://www.queness.com/resources/html/bgscroll/images/bg_clouds.png);background-size:cover;}
  26. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement