Advertisement
Guest User

Site1

a guest
Sep 21st, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.87 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <link rel="stylesheet" type="text/css" href="pindex.css"  />
  6. <title>Parallax Site</title>
  7.  
  8.        
  9.        
  10.         <style type="text/css">
  11.             body {
  12.                     margin: 0;
  13.                     padding: 0;
  14.                 }
  15.                
  16.             ul {
  17.                     margin:0;
  18.                     padding:0;
  19.                    
  20.             }
  21.            
  22.             ul li {
  23.                 list-style:none;
  24.                 overflow:hidden;
  25.                 height:600px;
  26.             }
  27.            
  28.            
  29.             .parallax-background{
  30.                 height:700px;  
  31.                
  32.                
  33.             }
  34.            
  35.             .turntables {
  36.                 background-image:url(images/turntables.jpg);
  37.                 background-position:70% 50%;
  38.             }
  39.            
  40.             .dogphones {
  41.                 background-image:url(images/dogphones.jpg);
  42.                 background-position:10% 60%;
  43.             }
  44.            
  45.             .mic {
  46.                 background-image:url(images/mic.jpg);
  47.                 background-position:100% 70%;
  48.             }
  49.            
  50.             .speakers {
  51.                 background-image:url(images/speakers.jpg);
  52.                 background-position:45% 100%;
  53.             }
  54.            
  55.             .bars {
  56.                 background-image:url(images/bars.jpg);
  57.                 background-position:45% 100%;
  58.             }
  59.        
  60.            
  61.             </style>
  62.        
  63. </head>
  64.  
  65. <body>
  66.  
  67.     <ul class="parallax-background">
  68.         <li>
  69.             <div class="parallax-background turntables"></div>
  70.         </li>
  71.         <li>
  72.             <div class="parallax-background dogphones"></div>
  73.         </li>
  74.         <li>
  75.             <div class="parallax-background mic"></div>
  76.         </li>
  77.         <li>
  78.             <div class="parallax-background speakers"></div>
  79.         </li>
  80.         <li>
  81.             <div class="parallax-background bars"></div>
  82.         </li>
  83.    </ul>
  84.            
  85.  
  86.  
  87.         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  88.         <script>
  89.        
  90.             (function($) {
  91.                
  92.                
  93.                     var $container = $(".parallax");
  94.                     var $divs = $container.find("div.parallax-background");
  95.                     var thingBeingScrolled = document.body;
  96.                     var liHeight = $divs.eq(0).closest("li").height();
  97.                     var diffHeight = $divs.eq(0).height() - liHeight;
  98.                    
  99.                     var i,len,div,li,offset,scroll,top;
  100.                    
  101.                     var render = function() {
  102.                        
  103.                         // thing were scrolling
  104.                         top =  thingBeingScrolled.scrollTop;
  105.                        
  106.                         //loop through divs
  107.                         for (i = 0, len=$divs.length; i < divs.length; i+scroll+) {
  108.                            
  109.                             // get one div
  110.                             div = $divs[i];
  111.                            
  112.                             // get the parent Li
  113.                             li = div.parentNode;
  114.                              
  115.                             // calculate the offsetTOP of div
  116.                             offset = $(divs).offset().top;
  117.                            
  118.                             // calculate the amount to scroll
  119.                             scroll = Math.round(((top - offset) / liHeight) * diffHeight);
  120.                            
  121.                             //apply the scroll amount
  122.                             div.style.webkitTransform = ""translate3d(0px,"+scroll+"px,0px")
  123.                        
  124.                     }
  125.                        
  126.                     };
  127.                    
  128.                     (function loop(){
  129.                         requestAnimationFrame(loop);
  130.                         render();
  131.                     })();
  132.                        
  133.             })(jQuery);
  134.             </script>
  135.             </body>
  136.             </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement