css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!--The Tutorial and propably best + easiest way to do Parallax Scrolling on many devices and many elements fast!: http://www.franckmaurin.com/the-parallax-effects-with-jquery/-->
<!--My (Jonathan Arbely) version of Franck Maurin's tutorial code has added comments, multiple sections instead of one and is tested on many, many devices: http://www.jonathanarbely.de-->
<!--Tested on: IE 6-11, FF 20-32, Safari 5-8, Chrome 28-37, Opera 24, iOS 6-8, Android 4: http://www.profi-homepage.de/ ...-->
<!--Next Version will include a "snap to parent" option, a beter way to animate and custom animations like rotate and transform-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Straightforward JQuery noPlugin Parallax Scrolling</title>
<meta name="author" content="Franck Maurin, Jonathan Arbely">
<!--JQuery 1.x will work on IE 6, 7 and 8-->
<script src="http://jonathanarbely.de/cdn/parallax/jquery-1.11.1.js"></script>

<body onLoad="pluginload();">
<div class="area1">
<div class="section element1"></div>
<div class="section element2"></div>
<div class="section element3"></div> 
<div class="area2">
<div class="section element4"></div>
<div class="section element5"></div>
<div class="section element6"></div>
<div class="area1">
<div class="section element7"></div>
<div class="section element8"></div>
<div class="section element9"></div>
              /*Three areas, each 1200px, in total 3600px, note the delay when I'm calling elements in js*/
html, body { height: 3600px; width: 100%; margin: 0; padding: 0; left: 0; top: 0; }
.area1 { background: #2b2b2b; height: 1200px; }
.area2 { background: #c12235; height: 1200px; }
div { overflow: hidden; }
.section { float: left; width:33.33%; height: 1200px; background:url(http://jonathanarbely.de/cdn/parallax/tri.png) no-repeat; }
.area2 .section { background:url(http://jonathanarbely.de/cdn/parallax/tri2.png) no-repeat; }:
              // Function to call the plugin and the callers AFTER DOM load
function pluginload()  {
// The plugin code
// Known issues and behaviours: 
// IOS fires y scroller position only on touchcancel which causes stuttering.
// Stuttering under Android 4.x is hardware related, chrome works smoother
// Windows Phone 7 same as iOS, Windows Phone 8 same as Android
	// Creates new Function "parallax" that receives up to three inputs (start, stop, coeff)
    $.fn.parallax = function(input){
		// New var is the targetet element
        var targetelement = $(this);
		// Get "targetelement" coordinates relative to document
        offset = targetelement.offset();
        // Create object containing four vars
		var defaults = {
            "start": 0, // Where the element should begin to scroll in px, not recommended
            "stop": offset.top + targetelement.height(), // Where the element shall stop scrolling in px, not recommended
            "coeff": 1, // Scroll speed (1 is default), can be + or -
			"delay": 0 // Instead of "start", when the element should start scrolling in px
		// Handle default and input options, .extend merges to objects together to new object "opts", first object "defaults" is overwritten by second object with user input "input"
        var opts = $.extend(defaults, input);
		// freaking magic
        return this.each(function(){
			// more magic
            $(window).bind('scroll', function() {
				// new var "windowTop" is the difference between the current vertical position of the scrollbar "scrollTop" and user defined "delay"
                windowTop = $(window).scrollTop()-defaults.delay/*+150*/; // real start delay
                // if "targetelement" is between user defined start and stop, apply animation
				if((windowTop >= opts.start) && (windowTop <= opts.stop)) {
					// var "newCoord" defines the new coordinates for "targetelement" and is created by multiplying the current vertical position of the scrollbar with user defined animation speed 
                    newCoord = windowTop * opts.coeff;
					// Apply the new coordinates to "targetelement" css "background-position"
                        "background-position": "0 "+ newCoord + "px"

// call the plugin for any desired element (call with .class)
$('.element1').parallax({ "coeff":2, "delay":0 });
$('.element3').parallax({ "coeff":1.2, "delay":0 });
$('.element2').parallax({ "coeff":4.55, "delay":0 });
$('.element4').parallax({ "coeff":0.2, "delay":1200 });
$('.element5').parallax({ "coeff":1.2, "delay":1200 });
$('.element6').parallax({ "coeff":2.2, "delay":1200 });
$('.element7').parallax({ "coeff":-0.2, "delay":2400 });
$('.element8').parallax({ "coeff":-1.2, "delay":2400 });
$('.element9').parallax({ "coeff":8, "delay":2400 });
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................