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

              
                .box1 
  %span.title Normal
.box2 
  %span.title 1/2 Speed Parallax
.box3 
  %span.title 1/4 Speed Parallax
.box4 
  %span.title Fixed Position
%h1 
  Scrolling Background-Image Parallax
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Bowlby+One+SC);

body{
background-image: linear-gradient(#9b59b6, #8E44AD 500px);
  font-family: "Bowlby One SC", sans-serif;
  color: #333;
}
div{
height: 3000px;
width: 20%;
margin: 2.5%;
float: left;
background: white;
  background-image: linear-gradient(#ECF0F1 50%, #bdc3c7 50%);
  background-size: 50px 50px;
  font-size: 20px;
  box-sizing: border-box;
  text-align: center;
  font-weight: bold;
  position: relative;
}

.box4{
  background-attachment: fixed;
  background-position: 0 26px;
}
h1 {
  position: fixed;
  bottom: 0px;
  width:100%;
  text-align: center;
  background: #F1C40F;
  padding: .5em 1em;
  box-sizing: border-box;
}
span { 
  display: block;
  position: fixed;
  width: 20%;
  box-sizing: border-box;
  padding: 3px 10px;
}
              
            
!

JS

              
                // The function
var background_image_parallax = function($object, multiplier){
  multiplier = typeof multiplier !== 'undefined' ? multiplier : 0.5;
	multiplier = 1 - multiplier;
  var $doc = $(document);
  $object.css({"background-attatchment" : "fixed"});
	$(window).scroll(function(){
	  var from_top = $doc.scrollTop(),
	      bg_css = '0px ' +(multiplier * from_top) + 'px';
	  $object.css({"background-position" : bg_css });
  });
};

//Just pass the jQuery object
background_image_parallax($(".box2"));

//optional second value for speed
background_image_parallax($(".box3"), 0.25);
              
            
!
999px

Console