Guest User

index.html

a guest
Jul 10th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  4. <style type="text/css" media="screen">
  5.  
  6. /* Give the header a height and a background image */
  7. #header{
  8. height:150px;
  9. background: #000 url(FTLogoTwitter.v14.jpg) repeat-y scroll left top;
  10. text-align:center;
  11. }
  12.  
  13. </style>
  14. </head>
  15. <body>
  16. <div id="wrapper">
  17. <div id="header">
  18. </div>
  19. </div>
  20. </body>
  21.  
  22. <!-- Import jQuery-->
  23. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
  24.  
  25. <script type="text/javascript" charset="utf-8">
  26. var scrollSpeed = 70; // Speed in milliseconds
  27. var step = 1; // How many pixels to move per step
  28. var current = 0; // The current pixel row
  29. var imageHeight = 4300; // Background image height
  30. var headerHeight = 300; // How tall the header is.
  31.  
  32. //The pixel row where to start a new loop
  33. var restartPosition = -(imageHeight - headerHeight);
  34.  
  35. function scrollBg(){
  36.  
  37. //Go to next pixel row.
  38. current -= step;
  39.  
  40. //If at the end of the image, then go to the top.
  41. if (current == restartPosition){
  42. current = 0;
  43. }
  44.  
  45. //Set the CSS of the header.
  46. $('#header').css("background-position","0 "+current+"px");
  47.  
  48.  
  49. }
  50.  
  51. //Calls the scrolling function repeatedly
  52. var init = setInterval("scrollBg()", scrollSpeed);
  53.  
  54. </script>
  55.  
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment