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

              
                <nav id="global-nav" aria-label="Main navigation">
  <ul>
    <li><a href="#">Posts</a></li>
    <li><a href="#">Talks</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>
<div id="container">
  <header role="banner">
    <div class="inner-header">
      <div class="header-flex">
        <h1 class="site-title">
      <!-- tabindex="1" so this link is always first in the tab order -->
           <a href="#" tabindex="1">
              Accessible Slide Menu
            </a>
         </h1>
        <button aria-controls="global-nav" aria-haspopup="true" tabindex="2" id="menu-button">
          <span class="menu-icon" aria-hidden="true">
            <svg version='1.1' x='0px' y='0px' width='30px' height='30px' viewBox='0 0 30 30' enable-background='new 0 0 30 30'><rect width='30' height='5'/><rect y='24' width='30' height='5' /><rect y='12' width='30' height='5'/></svg>
          </span>
          <span class="menu-text">Menu</span>
        </button>
      </div>
    </div>
  </header>
  <main>
    <section>
      <article>
        <h2>By <a href="http://marcysutton.com/">Marcy Sutton</a></h2>
        <h3>Some Bowie Ipsum for scrolling</h3>
        <p>Dignity is valuable, but our lives are valuable too. I would not challenge a giant. Hey, that's far out so you heard him too! Beware the savage jaw of 1984. Do you remember, the bills you have to pay?</p>
        <p>Throwing darts in lovers' eyes. Freak out!</p>
        <p>I've never done good things. As they pulled you out of the oxygen tent, you asked for the latest party. What you like is in the limo.</p>
      </article>
    </section>
  </main>
</div>
              
            
!

CSS

              
                html, body {
  font-family: Roboto, Helvetica,sans-serif;
  margin: 0;
  padding: 0;
}

// Nav comes first in DOM order
nav#global-nav {
  background-color: #333;
  bottom: 0;
  max-width: 220px;
  overflow: auto;
  position: fixed;
  top: 0;
  right: -220px;
  width: 100%;
  z-index: 0;
  -moz-transition: all 300ms;
  -o-transition: all 300ms;
  -webkit-transition: all 300ms;
  transition: all 300ms;
  
  // slide in menu when .active class is added by JS
  body.active & {
    -moz-transform: translateX(-220px);
    -ms-transform: translateX(-220px); 
    -webkit-transform: translateX(-220px);
    transform: translateX(-220px);
  }
  
  ul {
    margin: 0;
    padding: 1em 0 0;
  
    li {
      border-bottom: 1px solid #474747;
      padding: 0;
      margin: 0;
      width: 100%;
      
      a {
        display: block;
        color: #fff;
        text-decoration: none;
        padding: 1.5em 0 1.5em 2em;
        
        &:hover,
        &:focus {
          background-color: #474747;
        }
        &:active {
          color: #9fbf00;
        }
      }
    }
  }
}

#container {
  position: relative;
  top: 0;
  right: 0;
  width: 100%;
  -moz-transition: all 300ms;
  -o-transition: all 300ms;
  -webkit-transition: all 300ms;
  transition: all 300ms;
  
  // Important detail for mobile: 
  //   container must be positioned on top of nav
  z-index: 1;

  // slide out container when .active class is added by JS
  body.active & {
    -moz-transform: translateX(-220px);
    -ms-transform: translateX(-220px); 
    -webkit-transform: translateX(-220px);
    transform: translateX(-220px);
  }
}
a {
  color: darkblue;
}
// Header
header[role=banner] {
  background-color: #333;
  box-shadow: -1px 3px 6px #13140F;
  padding: 1em 0;
  text-align: left;

  .inner-header {
    position: relative;
    padding: 0 1rem;
  }
  .header-flex {
    display: -webkit-flex;
    display: flex;
  }
  .site-title {
    font-family: 'Kaushan Script', cursive;
    font-weight: normal;
    font-size: 2.5rem;
    letter-spacing: 0.05em;
    line-height: 1;
    margin: 0.25em 0 0;

    a {
      color: #f7ffea;
      text-shadow: 2px 2px 4px #13140F;
      text-decoration: none;
    }
  }
}
#menu-button {
  background-color: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  display: block;
  line-height: 1;
  min-width: 47px;
  margin: 0.5rem 0 auto auto;
  padding: 0;
  position: relative;
  text-align: center;
  z-index: 1;
  -moz-transition: all 300ms;
  -o-transition: all 300ms;
  -webkit-transition: all 300ms;
  transition: all 300ms;
  
  span.menu-icon {
    display: block;
    pointer-events: none;
    font-size: 3em;
    text-shadow: 2px 2px 2px #333;
    
    svg rect {
      fill: #fff;
    }
  }
  span.menu-text {
    display: block;
    font-size: 1.15em;
    margin-top: 0.5em;
  }
}
// Main content area
main {
  padding: 0 1rem;
  
  section {
    min-height: 700px;
  }
}
/* Utilities */
.visuallyhidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px
}
              
            
!

JS

              
                
var MS = {};

MS.App = (function() {

  var ESCAPE_CODE = 27;

  var navButton = $('#menu-button'),
      navMenu = $('#global-nav');
  
  var navLinks = navMenu.find('a');

  function initApp() {
    navMenu.on('keydown', handleKeydown);
    navButton.on('click', handleClick);
    disableNavLinks();
  }
  function handleKeydown(event) {
    if (event.keyCode === ESCAPE_CODE) {
      document.body.classList.toggle('active');
      disableNavLinks();
      navButton.focus();
    }
  }
  function handleClick(event) {
    if (document.body.classList.contains('active')) {
      document.body.classList.remove('active');
      disableNavLinks();
    }
    else {
      document.body.classList.add('active');
      enableNavLinks();
      navLinks.eq(0).focus();
    }
  }
  function enableNavLinks() {
    navButton.attr('aria-label', 'Menu expanded');
    navMenu.removeAttr('aria-hidden');
    navLinks.removeAttr('tabIndex');
  }
  function disableNavLinks() {
    navButton.attr('aria-label', 'Menu collapsed');
    navMenu.attr('aria-hidden', 'true');
    navLinks.attr('tabIndex', '-1');
  }

  return {
    init: function(){
      initApp();
    }
  }
})();

$(document).ready(function($) {
  new MS.App.init();
});
              
            
!
999px

Console