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="body">
  <header>
    <h1><a href="/">Jonno Witts</a></h1>
    <span class="menu-control-open" id="menuControlOpen">
      <svg width="10" height="15">
          <circle r="3" cx="5" cy="5"></circle>
          <line x1="5" x2="5" y1="7" y2="13"></line>
      </svg>
      Menu
    </span>
    <div class="menu">
        <div class="menu-inner">
            <span class="menu-control-close" id="menuControlClose">Close</span>
            <nav>
                <a href="#">Work</a>
                <a href="#">Notes</a>
                <a href="#">Info</a>
            </nav>
            <span class="version">2017.0.1</span>
            <span class="madeIn">Made in England</span>
        </div>
    </div>
  </header>
</div>
              
            
!

CSS

              
                /* GENERAL STYLING: NOT NECESSARY */
html {
  font-size: 10px; }
body {
  line-height: 1;
  font-family: "Futura", "Helvetica", "Arial", sans-serif; }
nav {
  display: block; }
nav ul {
  list-style: none; }
a {
  margin: 0;
  padding: 0;
  font-size: 100%;
  vertical-align: baseline;
  background: transparent; }
*, *:before, *:after {
  box-sizing: border-box; }
::-moz-selection {
  background: #ff6060;
  color: #373331; }
::selection {
  background: #ff6060;
  color: #373331; }

body {
  letter-spacing: 0.03rem;
  width: 100%;
  background-color: #00afaf; }
/* END OF GENERAL STYLING */

/* START OF USEFUL CODE */
header {
  position: absolute;
  overflow: visible;
  z-index: 100;
  background-color: transparent;
  width: 100%;
  height: 5rem;
  padding: 1.5rem;
  
  h1 {
    font-size: 2.2rem;
    float: left; 
    margin-top: 5px;
  }
  
  a {
    text-decoration: none; 
  }
  
  span.menu-control-open,
  span.menu-control-close,
  nav,
  a {
    font-weight: bold;
    text-transform: uppercase;
    color: #F0F0F0; 
  }
  
  span.menu-control-open,
  span.menu-control-close,
  nav a {
    font-size: 2.2rem;
    margin-bottom: 1.5rem; 
  }
  
  span.menu-control-open,
  span.menu-control-close {
    display: block;
    cursor: pointer; 
  }
  
  span.menu-control-open {
    position: relative;
    font-size: 1.2rem;
    line-height: 150%;
    float: right;
    margin-top: 5px;
    svg {
        position: absolute;
        top: -12px;
        left: 12px;
        line, circle {
            fill: none;
            stroke: #ffffff;
            stroke-width: 3;
        }
    }
    &:before {
        padding-top: 1px;
    }
    &:before, &:after {
        content: '';
        display: block;
        width: 100%;
        border-top: 3px solid wheat;
    }
  }
  
  span.menu-control-close {
    font-size: 1.2rem;
    text-align: right; 
  }
  
  nav {
    display: flex;
    flex-direction: column; 
  }
}

.menu {
  position: absolute;
  right: 0;
  top: 0;
  background-color: #373331;
  color: #F0F0F0;
  height: 100vh;
  width: 0;
  overflow: hidden;
  transition: all .3s ease-in-out;
  a {
    transform: translate3d(-150px, 0, 0);
    transition: transform .15s ease-in; 
  }
  
  .menu-inner {
    position: relative;
    height: 100%;
    width: 80vw;
    padding: 1.5rem; 
  }

  /* Unnecessary styles for the menu footer */
  .version, .madeIn {
    position: absolute;
    bottom: 1.5rem;
    font-size: 1.2rem;
    text-transform: uppercase;
    font-weight: bold; 
  }
  .version {
    right: 1.5rem; 
  }
}

.menu--active {
  height: 100vh;
  overflow: hidden; 
  
  nav a {
    transform: translate3d(0, 0, 0);
    transition: transform 500ms ease-out; 
  
    /* Handles items within the slide-out to give them the delayed slide-in */
    &:first-child {
      transition-delay: .2s; 
    }
    &:nth-child(2) {
      transition-delay: .3s; 
    }
    &:last-child {
      transition-delay: .4s; 
    }
  }
}

// This media query sets the width of the menu to be larger on a smaller screen
 @media screen and (max-width: 767px) {
  .menu--active .menu {
    width: 80%; }
}

// This media query sets the menu width to be slightly smaller on a larger screen (think an iPad)
@media screen and (min-width: 768px) and (max-width: 1024px) {
  .menu--active .menu {
    width: 40%;
    .menu-inner {
      width: 40vw;
    }
  }
}
  
// This media query styles the menu for a large environment (think a desktop)
@media screen and (min-width: 1024px) {
  header {
    height: 7rem;
    padding: 2.5rem;
    
    span.menu-control-open,
    span.menu-control-close {
      display: none; 
    }
    
    .menu {
      position: static;
      overflow: visible;
      background-color: transparent;
      width: auto;
      height: auto; 
      
      .menu-inner {
        padding: 0;
        width: 100%; 
      }
      
      a {
        transform: none;
        transition: none; 
      }
      
      .version,
      .madeIn {
        bottom: -90.85vh;
        letter-spacing: 1px;
        font-size: 1.3rem; 
      }
    }
  
    nav {
      flex-direction: row;
      justify-content: flex-end;
      a {
        font-size: 2.65rem;
        margin-left: 4rem; 
      }
    }
  }
}
              
            
!

JS

              
                
            var body = document.getElementById('body');
            var openMenu = document.getElementById('menuControlOpen'); // or whatever triggers the toggle
            var closeMenu = document.getElementById('menuControlClose'); // or whatever triggers the toggle

            openMenu.addEventListener('click', function(e) {
               body.classList.toggle('menu--active'); // or whatever your active class is
            });

             closeMenu.addEventListener('click', function(e) {
                body.classList.toggle('menu--active'); // or whatever your active class is
            });


        
              
            
!
999px

Console