Layout + parallax scrolling

Découvrez l'exemple

Exemple de changement de fond lorsqu'on scroll

<div class="layer">
  <h1>Intro</h1>
  <p>Exemple de changement de fond lorsqu'on scroll</p>
</div>
<div class="bg b1"></div>
<div class="layer">
  <h1>Layer 1</h1>
</div>
<div class="bg b2"></div>
<div class="layer">
  <h1>Layer 2</h1>
</div>
<div class="bg b3"></div>
<div class="layer">
  <h1>Layer 3</h1>
</div>
body {
  margin:0;
  padding:0;
  font-family: "Arial";
}
 
h1, p {
  margin:0;
}
 
p:after {
  display: block;
  content: " \25BC";
  font-size:30px;  
}
 
.layer {
  position:relative;
  width: 100%;
  min-height: 180px;
  background: #fff;
  color:#000;
  font-size:25px;
  text-align:center;
  padding: 30px 0;
 
  z-index:100;
  box-shadow: 0 0 15px 0 #000;
}
 
.bg {
  height: 300px;
  width:100%;
}
 
.b1 { background:url(https://www.w4u.fr/themes/w4u/images/code.jpg); }
.b2 { background:url(https://www.w4u.fr/sites/default/files/2017-04/expertise4.jpg); }
.b3 { background:url(https://www.w4u.fr/sites/default/files/2017-04/nos_offres.jpg); }
var ease = 1;
 
$(function() {
  $(document).scroll(function() {
    var scrolled = $(document).scrollTop();
    $('.bg').css( 'background-position', '0 ' + ( scrolled * ease ) + 'px' );
  });
});