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

              
                <button>Start</button>
<div class="header">SITE NAME</div>
<div class="content">

<div class="main">
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!</p>

  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!</p>
</div>
  
</div>

<div class="footer">COPYRIGHT FOOTER</div>
              
            
!

CSS

              
                html, body{
  height: 100%;
  width: 100%; 
}

body{
  margin: 0;
  padding: 0;
  color: white;
}
button {
  top: 10px;
  right: 15px;
  position: absolute;
  z-index: 3;
}
.header, .footer {
  background: blue;
  width: 100%;
  height: 44px;
  line-height: 44px;
  padding: 0 20px;
  position: absolute;
  z-index: 2;
}

.footer{
  bottom: 0;
}

.main {
  padding: 50px 20px; /* 50px for header + footer  */
  position: relative;
  background: red;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  position: absolute;
}

.main.new_content {
  /*background: lime;*/
}
              
            
!

JS

              
                $('button').on('click', function(){
  
  var oldSection = $('.main').addClass('old_content');
  var $wrapper = $('<div class="main">NEW CONTENT FROM SERVER</div>'); 
  var newSection = $wrapper.addClass('new_content').appendTo('.content');
  
  //instantiate a TimelineLite    
  var tl = new TimelineLite();
					
  tl.to(oldSection, 1, {x:'-100%', onComplete:oldComplete, ease: Power1.easeInOut})
    .from(newSection, 1, {x:'100%', backgroundColor: 'lime', onComplete:newComplete, ease: Power1.easeInOut},"-=1");
  
    function newComplete() {
      $(newSection).removeClass('new_content');
    }
    function oldComplete() {
      $(oldSection).remove();
    }
 });
              
            
!
999px

Console