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

              
                <div id="stage">
  <div class="box" id="box1"></div>
  <div class="box" id="box2"></div>
  <div class="box" id="box3"></div>
</div>

[[[https://codepen.io/davestewart/pen/itCkj]]]

              
            
!

CSS

              
                /* layout */
body{
  width:800px;
  font:12px normal "Arial", sans-serif;
}

#stage {
  position:relative;
  height:200px;
  background-color:black;
}

/* elements */
.box {
  width:50px;
  height:50px;
  position:absolute;
}

#box1 { 
  background-color:red;
}

#box2 { 
  background-color:blue; 
  left:200px;
}
#box3 { 
  background-color:green; 
  left:600px;
}


              
            
!

JS

              
                // timeline generator
	var pauseCount = 1;
	function addPause(tlParent, box, time)
	{
    // set boxes to bottom
    	TweenLite.set(box, {top:150});
    
    // timeline, shifted back
    	var tl = new TimelineLite({delay:-0.5});
    	tl.to(box, 0.5, {top:50, ease:none});
    	tl.to(box, 0.5, {top:150, ease:none});
    
    // add new timeline
    	tlParent.add(tl, time);
    
    // pause existing timeline
    	var label = 'pause' + (pauseCount++);
    	tlParent
      	.addLabel(label, time)
      	.addPause(label);
	}

// elements
  var box1 = $('#box1').get(0);
  var box2 = $('#box2').get(0);
  var box3 = $('#box3').get(0);

// variables
	var none = Power0.easeOut;

// timeline
	var tl = new TimelineMax();

// animate main box
	tl.to(box1, 10, {left:800, ease:none}, 0);

// animate extra boxes
	addPause(tl, box2, 2.5);
	addPause(tl, box3, 7.5);
  
// init ocntroller
	Controller.init(tl, '#animation');



              
            
!
999px

Console