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

              
                <div>
    <nav>
      <a href="" data-target="#target1">Target 1</a>
      <a href="" data-target="#target2">Target 2</a>
      <a href="" data-target="#target3">Target 3</a>
      <a href="" data-target="#target4">Target 4</a>
      <a href="" data-target="#target5">Target 5</a>
      <a href="" data-target="#target6">Target 6</a>
      <a href="" data-target="#target7">Target 7</a>
      <a href="" data-target="#target8">Target 8</a>
      <hr>
      <a href="" data-target="#start">Top</a>
    </nav>
  </div>

  <div class="block flex" id="target1">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 1</div>
    </div>
  </div>
  <div class="block flex" id="target2">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 2</div>
    </div>
  </div>
  <div class="block flex" id="target3">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 3</div>
    </div>
  </div>
  <div class="block flex" id="target4">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 4</div>
    </div>
  </div>
  <div class="block flex" id="target5">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 5</div>
    </div>
  </div>
  <div class="block flex" id="target6">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 6</div>
    </div>
  </div>
  <div class="block flex" id="target7">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 7</div>
    </div>
  </div>
  <div class="block flex" id="target8">
    <div class="block-target flex flex-item">
      <div class="flex flex-item">Target 8</div>
    </div>
  </div>
              
            
!

CSS

              
                body {
  background-color: #444;
  margin: 15px;
}

nav {
  background-color: #fefefe;
  border: 1px solid #999;
  position: fixed;
  top: 0;
  left: 0;
  padding: 20px 20px 10px;
}

nav a {
  display: block;
  margin: 4px 0;
}

.block {
  font-family: sans-serif;
  padding: 15px;
  background-color: seagreen;
  border: 0px solid #555;
  margin-bottom: 15px;
  height: calc(100vh - 60px);
}

.block-target {
  border: 3px solid #eee;
  color: #eee;
  font-size: 30px;
  height: 200px;
  height: 50%;
  max-width: 50%;
}

.flex {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-item {
  flex: 1;
}
              
            
!

JS

              
                $(function() {
  
  var $document = $(document);
  var $window   = $(window);
  var height    = $document.height() - $window.height();
  var timeline  = new TimelineMax();
  var totalTime = 4.5;
  var direction;
  var duration;
  var ratio;
  
  var key = {
    down : 40,
    up   : 38
  };
  
  var scrolling = {
    down : "down",
    up   : "up"
  };
  
  // ===========================================================================
  //  KEY DOWN
  // ===========================================================================
  $document.on("keydown", function(event) {
    
    // DOWN KEY
    if (event.keyCode === key.down) {
      event.preventDefault();
      
      if (direction !== scrolling.down) {
        
        ratio     = $window.scrollTop() / height;
        duration  = totalTime * (1 - ratio);
        direction = scrolling.down;
                
        timeline.to($window, duration, { scrollTo: "max", ease: Power1.easeInOut });
      }
    }
    
    // UP KEY
    if (event.keyCode === key.up) {
      event.preventDefault();
      
      if (direction !== scrolling.up) {
        
        ratio     = $window.scrollTop() / height;
        duration  = totalTime - (totalTime * (1 - ratio));
        direction = scrolling.up;
        
        timeline.to($window, duration, { scrollTo: 0,  ease: Power1.easeInOut });
      }
    }
  });
  
  // ===========================================================================
  //  KEY UP
  // ===========================================================================
  $document.on("keyup", function(event) {
    
    if (event.keyCode === 40 || event.keyCode === 38) {
      event.preventDefault();
      timeline.kill().clear();
      direction = null;
    }
  });
  
  // ===========================================================================
  //  NAV SCROLL
  // ===========================================================================
  $("a").click(function(event) {
    
    event.preventDefault();
    
    var target   = $(this).data("target");    
    var scrollTo = (target !== "#start") ? $(target).offset().top - 15 : 0 ;
    
    TweenMax.to(window, 1, { scrollTo: scrollTo, ease: Power2.easeOut });
  });
});

              
            
!
999px

Console