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

              
                <html>
  <body>
  <header class="page-head">

    <a href="#" class="page-head__home-link"> </a>

    <a href="#" class="page-head__toggle"><span>Menu</span></a>
    <nav class="site-nav">
      <ul class="site-nav__list">
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 1</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 2</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Services</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 3</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 4</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 5</a></li>
      </ul>
    </nav>

  </header>
</body>
</html>

              
            
!

CSS

              
                /**
 * Base.
 */

html {
  background: #fff;
  font-size: 62.5%;
}

body {
  background-color: #fff;
  font-size: 16px;
  height: 1500px;
  margin: 110px 0 0;
  padding: 0;
  text-rendering: optimizeLegibility;
}


/**
 * Header.
 */

.page-head__home-link {
  background: #93b833;
  float: left;
  height: 52px;
  line-height: 0;
  margin-left: 2.5%;
  position: relative;
  transition: fill .25s;
  width: 140px;
  z-index: 2000;
}

.page-head {
  background: #222;
  box-sizing: border-box;
  height: 110px;
  overflow: hidden;
  padding-top: 30px;
  position: absolute;
  top: 0;
  right: 0;
  transform: translateY(0) translateZ(0);
  transition: background .10s, height .20s, padding .10s, transform .25s;
  width: 100%;
  z-index: 2000;
  &.invisible {
    opacity: 0;
    transform: translateY(-100%) translateZ(0);
    transition: transform .25s;
  }
  &.detached {
    background: #f00;
    height: 70px;
    opacity: 1;
    padding-top: 10px;
    position: fixed;
  }
}


/**
 * Navigation.
 */

.show-nav {
  overflow: hidden;
}

.site-nav {
  background: transparent;
  display: block;
  height: 100%;
  overflow: hidden;
  position: fixed;
  top: 0;
  text-align: center;
  transform: translate3d(0, 0, 0);
  transition: background .75s ease;
  user-select: none;
  visibility: hidden;
  width: 100%;
  z-index: -1;
  .show-nav & {
    background: rgba(#93b833, .98);
    overflow-y: auto;
    visibility: visible;
    z-index: 1000;
  }
  .hide-nav & {
    background: transparent;
    height: 100%;
    visibility: visible;
    width: 100%;
    z-index: 1000;
  }
}

.site-nav__list {
  margin: 0;
  padding: 0;
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translateY(-50%);
  width: 100%;
}

.site-nav__item {
  margin: 0;
  opacity: 0;
  transform: translateY(-100px);
  transition: all .5s 0s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  .show-nav & {
    opacity: 1;
    transform: translateY(0);
    transition-delay: .25s;
    transition-duration: 1s;
  }
}

.site-nav__link {
  background: transparent;
  color: #fff;
  display: block;
  font-size: 40px;
  line-height: 40px;
  font-style: italic;
  font-weight: 600;
  padding: 10px 0;
  transition: none;
  &:visited {
    background: transparent;
    color: #fff;
  }
  &:hover,
  &:focus {
    background: #fff;
    color: #93b833;
  }
}


/**
 * Toggle.
 */

.page-head__toggle {
  cursor: pointer;
  display: block;
  height: 55px;
  float: right;
  position: relative;
  right: 2.5%;
  text-indent: -9999px;
  transition: all .25s ease-in;
  width: 55px;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-touch-callout: none;
  user-select: none;
  z-index: 9999999999999;
  &:focus {
    outline: none;
  }
  span {
    background: #93b833;
    display: block;
    height: 3px;
    position: absolute;
    top: 26px;
    right: 10px;
    left: 10px;
    &:before,
    &:after {
      background: #93b833;
      content: "";
      display: block;
      height: 3px;
      position: absolute;
      top: -8px;
      left: 0;
      width: 100%;
    }
    &:after {
      top: auto;
      bottom: -8px;
    }
    .show-nav & {
      background: #fff;
      &:before,
      &:after {
        background: #fff;
      }
    }
  }
}

.page-head__toggle span {
  transition: background 0s .25s;
}

.page-head__toggle span:before,
.page-head__toggle span:after {
  transition-duration: .25s, .25s;
  transition-delay: .25s, 0s;
}

.page-head__toggle span:before {
  transition-property: top, transform;
}

.page-head__toggle span:after {
  transition-property: bottom, transform;
}


/* active state, i.e. menu open */

.show-nav {
  .page-head__toggle span {
    background: none !important;
  }
  .page-head__toggle span:before {
    top: 0;
    transform: rotate(45deg);
  }
  .page-head__toggle span:after {
    bottom: 0;
    transform: rotate(-45deg);
  }
  .page-head__toggle span:before,
  .page-head__toggle span:after {
    transition-delay: 0s, .25s;
  }
}
              
            
!

JS

              
                /* ==========================================================================
   #SHOW/HIDE HEADER
   ========================================================================== */

$(function() {

  var previousScroll = 0, // previous scroll position
    menuOffset = 70, // height of menu (once scroll passed it, menu is hidden)
    detachPoint = 220, // point of detach (after scroll passed it, menu is fixed)
    hideShowOffset = 5, // scrolling value after which triggers hide/show menu
    header = $('.page-head');

  $(window).scroll(function() {

    if (header.hasClass('expanded')) return;

    var currentScroll = $(this).scrollTop(),
      scrollDifference = Math.abs(currentScroll - previousScroll);

    // if scrolled past menu
    if (currentScroll > menuOffset) {
      // if scrolled past detach point add class to fix menu
      if (currentScroll > detachPoint) {
        var value = parseInt(header.css('transform').split(',')[5]);
        console.log(value);
        if (!header.hasClass('transitioning') && !header.hasClass('detached') && value != -110) {
          header.addClass('transitioning').one('transitionend', function() {
            console.log('transitionend');
            header.removeClass('transitioning');
            if (currentScroll > detachPoint) header.addClass('detached');
          });
        } else if (!header.hasClass('transitioning') && !header.hasClass('detached')) {
          header.addClass('detached');
        }
      }

      // if scrolling faster than hideShowOffset hide/show menu
      if (scrollDifference >= hideShowOffset) {
        if (currentScroll > previousScroll) {
          // scrolling down; hide menu
          if (!header.hasClass('invisible'))
            header.addClass('invisible');
        } else {
          // scrolling up; show menu
          if (header.hasClass('invisible'))
            header.removeClass('invisible');
        }
      }
    } 
    // only remove “detached” class if user is at the top of document (menu jump fix)
    if (!currentScroll) {
        header.removeClass('detached');
      }
    
    // If user is at the bottom of document show menu.
    if ($(window).height() + currentScroll == $(document).height()) {
      header.removeClass('invisible');
    }

    // Replace previous scroll position with new one.
    previousScroll = currentScroll;
  });
});

/* ==========================================================================
   #SHOW/HIDE NAVIGATION
   ========================================================================== */

/* 
 * Creates classes to enable responsive navigation.
 */

// Wait for the DOM to be ready (all elements printed on page regardless if 
// loaded or not).
$(function() {

  // Bind a click event to anything with the class "toggle-nav".
  $('.page-head__toggle').click(function() {
    if ($('body').hasClass('show-nav')) {
      $('body').removeClass('show-nav').addClass('hide-nav');

      setTimeout(function() {
        $('body').removeClass('hide-nav');
      }, 500);

    } else {
      $('body').removeClass('hide-nav').addClass('show-nav');
    }
    // Deactivate the default behavior of going to the next page on click.
    return false;
  });
});
              
            
!
999px

Console