background-position property. The effect of Parallax Scrolling is that the background moves slower than the content."data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
   "data-type"  "data-speed" : 
 <section id="home" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article>  Parallax Scrolling</article> </section> 
        JavaScript, data-type        . 
 
  
 CSS  
       id #home  #about 
 #home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; } 
 home-bg.jpg 
  
 
 
 about-bg.jpg 
  
 
 
      : 
 #home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } 
 
 JavaScript - jQuery 
      data-type="background" : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   }); }); 
   .scroll()  .each() ,    : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { ... }); }); }); 
       : 
 var yPos = -($(window).scrollTop() / $bgobj.data('speed')); 
  
 
 
   background-position      coords : 
 var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords }); 
 
  : 
 $(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); //   $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); //   //   background-position var coords = 'center '+ yPos + 'px'; //   Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); }); 
  
    . 
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
"data-type" "data-speed" :
<section id="home" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section> <section id="about" data-type="background" data-speed="10" class="pages"> <article> Parallax Scrolling</article> </section>
JavaScript, data-type .
CSS
id #home #about
#home { background: url(home-bg.jpg) center 0 repeat fixed; min-height: 1200px; } #about { background: url(about-bg.jpg) center 0 no-repeat min-height: 1200px; }
home-bg.jpg

about-bg.jpg

:
#home { background: url(home.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; } #home article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; } #about { background: url(about.jpg) center 0 repeat fixed; min-height: 1000px; height: 1000px; margin: 0 auto; width: 100%; max-width: 1920px; position: relative; -webkit-box-shadow: 0 0 50px rgba(0,0,0,0.8); box-shadow: 0 0 50px rgba(0,0,0,0.8); } #about article { height: 458px; position: absolute; text-align: center; top: 300px; width: 100%; }
JavaScript - jQuery
data-type="background" :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // }); });
.scroll() .each() , :
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { ... }); }); });
:
var yPos = -($(window).scrollTop() / $bgobj.data('speed'));

background-position coords :
var coords = 'center '+ yPos + 'px'; $bgobj.css({ backgroundPosition: coords });
:
$(document).ready(function(){ $('section[data-type="background"]').each(function(){ var $bgobj = $(this); // $(window).scroll(function() { var yPos = -($window.scrollTop() / $bgobj.data('speed')); // // background-position var coords = 'center '+ yPos + 'px'; // Parallax Scrolling $bgobj.css({ backgroundPosition: coords }); }); }); });
.
Source: https://habr.com/ru/post/161875/
All Articles