Pen Settings

HTML

CSS

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

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

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.

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

              
                <h1>Demo 4: Synchronising Playback with the Scrollbar</h1>

<p>A responsive sprite animation that is synchronised with the scrollbar, and that remains in a fixed position for its duration of 1500 pixels. Scroll up and down to control playback.</p>

<div class="container" id="js-pinned">
  <div class="cnc" id="js-animation"></div>
</div>

<p class="p">Demo by Tom Bennet. <a href="http://www.sitepoint.com/responsive-sprite-animations-imagemagick-greensock" target="_blank">See article</a>.</p>
              
            
!

CSS

              
                body {
  padding: 20px;
  text-align: center;
}

.container {
  font-size: 15em;
  min-height: 110vh;
}

.cnc {
  margin: auto;
  width: 1em;
  height: 1em;
  background:  url('http://bennet.org/images/codepen/cnc-sprite-demo.png') no-repeat 0 0%;
  background-size: 100%;
}

h1 {
  font-size: 1.2em;
}

p {
  width: 60%;
  margin: auto;
  text-align: left;
}

.p {
  margin-top: 120px;
  font-size: 14px;
  text-align: center;
}
              
            
!

JS

              
                // initialise ScrollMagic controller
var controller = new ScrollMagic.Controller();

// create Tween
var tween = TweenMax.to("#js-animation", 1.0, {
	backgroundPosition: "0 100%", 
	ease: SteppedEase.config(31)
})

// build scene
var scene = new ScrollMagic.Scene({duration: 1500})
	.triggerHook("onCenter")
	.setPin("#js-pinned")
	.setTween(tween)
	.addTo(controller);
              
            
!
999px

Console