Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>Parallax</title>
</head>
<body class="parallax">
  <img class="parallax-img" src="https://i.imgur.com/YzvjiIb.png" alt=""  data-vel_x="0.001" data-vel_y="0.011" data-offset_x="-10" data-offset_y="70" />
  <img class="parallax-img" src="https://i.imgur.com/YUe9iXn.png" alt=""  data-vel_x="0.01" data-vel_y="0.04" data-offset_x="-120" data-offset_y="30"  />
  <div class="parallax-img nuvem" alt=""  data-vel_x="0.052" data-vel_y="0.002" data-offset_x="-1000" data-offset_y="" > </div>
  
  <div id="parallax-cfg"
    data-bg="https://i.imgur.com/U2s73nq.jpg"
    data-img1="https://i.imgur.com/cDml3Zx.png"
    data-img2="https://i.imgur.com/YUe9iXn.png"
    data-img3="https://i.imgur.com/YzvjiIb.png">&nbsp;</div>
  <div id="main-wrapper">
    <h1>The Parallax Behind This</h1>
     <p>Just the Main Wrapper</p>
    
  </div> 
</body>
</html>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lobster);
body {
  font-size: 15px;
}
.parallax {
width: 100%;
height: 100%;
position: relative;
}
#parallax-cfg {
  display: none;
}
#main-wrapper {
  display:block;
  width: 460px;
  height: 3000px;
  margin: 0 auto;
  border: 1px solid #ccc;
  min-height: 400px;
  padding: 40px;
  background: url('https://subtlepatterns.com/patterns/lined_paper.png') top left repeat;
  -webkit-border-radius: 28px;
  border-radius: 28px; 
  
}
#main-wrapper h1 {
  width: 100%;
  text-align: center;
  display: block;
  font-size: 3.4em;
  font-family: 'Lobster', cursive;
  color:brown;
  text-shadow: 2px 2px 0px #ffffff;
  filter: dropshadow(color=#ffffff, offx=1, offy=1);
}
#main-wrapper p {
   font-family: 'Lobster', cursive;
   font-size: 1.3em;
  text-align: center;
}
.parallax-img {
  position: fixed;
  
}

.nuvem {
  
  background: url('https://i.imgur.com/cDml3Zx.png') top left repeat-x;
  width: 300%;
  height: 200px;
  z-index: -1;
}
              
            
!

JS

              
                var nanaMaster = $(window).height();

$('.nuvem').attr('data-offset_y', nanaMaster);
var nana1 = $('.nuvem').data("offset_y");

function inkmotion_Parallax(){
 var bg = $('#parallax-cfg').data('bg');
 var img1 = $('#parallax-cfg').data('img1');
 var img2 = $('#parallax-cfg').data('img2');
 var img3 = $('#parallax-cfg').data('img3');
 $('body').css({background : 'url(' + bg + ') fixed top left no-repeat'});
}
var default_x = ($(document).width()/2 - $('#main-wrapper').width());
var default_y = 50;
var scroll_y = $('body').scrollTop();
inkmotion_Parallax();
$(window).mousemove(function(event) {
  move();
  }); 
$(window).scroll(function(){
   move();                     
});
$(window).resize(function() {
   default_x = ($(document).width()/2 - $('#main-wrapper').width());
  move();
});
function move(){
  var cursor_x = event.pageX;
  var cursor_y = event.pageY;
  $('.parallax-img').each(function (){
    var vel_x = $(this).data('vel_x');
    var vel_y = $(this).data('vel_y');
    var offset_x = $(this).data('offset_x');
    var offset_y = $(this).data('offset_y');
    var new_x = -cursor_x*vel_x + default_x+offset_x;
    var new_y = -cursor_y*vel_y + default_y+offset_y;
    $(this).css({"left" : new_x});
    $(this).css({"top" : new_y});
  })
}
              
            
!
999px

Console