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

              
                <input hidden aria-hidden="true" type="checkbox" name="toggle-nav" id="toggle-id"/>
<aside>
  <header role="banner">
    <nav>
      <label for="toggle-id">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
          <path d="M2,2L18,18M18,2L2,18"/>
        </svg>
        Close Menu
      </label>
    </nav>
  </header>
  <ul>
    <li><a href="#">Option</a></li>
    <li><a href="#">Stuff</a></li>
    <li><a href="#">Nonsense</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Help</a></li>
  </ul>
</aside>
<main>
  <header role="banner">
    <nav>
      <label for="toggle-id">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
          <path d="M2,2l16,0m-16,8l16,0m-16,8l16,0"/>
        </svg>
        Menu
      </label>
      <b>Logo</b>
    </nav>
  </header>
  <article>
    <h1>The main title</h1>
    <p>Sometimes you don't even need JavaScript to do the core interactive functionality of your website. Sometimes just CSS is more than enough, when you understand how it really works.</p>
    <p>For more details about this feel free to read the accompanying post on <a href="http://darksnow.net/code/off-canvas-without-javascript">my blog</a>.</p>
  </article>
</main>
    
              
            
!

CSS

              
                $menu-width: 200px;

body {
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  font-size: 1rem;
  line-height: 1.618em;
}

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

aside {
  position: fixed;
  height: 100%;
  z-index: 1;
  background: #333;
  width: $menu-width;
  overflow-x: hidden;
}

main {
  z-index: 2;
  background: white;
  position: fixed;
  transition: transform 1s;
  overflow-y: auto;
}
article {
  padding: 1em;
}

header {
  background: #39f;
  padding: 0.5em 1em;
}
nav {
  display: flex;
  b {
    flex-grow: 1;
    text-align: right;
  }
}
svg {
  height: 1em;
  vertical-align: middle;
}
path {
  stroke: black;
  stroke-width: 3;
}
h1 {
  font-size: 2em;
  font-weight: bold;
}
p {
  margin-top: 1em;
}
a {
  color: #ff8133;
  font-weight: bold;
  text-decoration: none;
}
ul {
  padding: 1em;
}
/* Since all labels for the for attribute are
 * clickable, make them look like they are. */
label[for] {
  cursor: pointer;
}
/* Make sure the hidden checkbox is really hidden
 * from all consumers of this content. */
input[hidden] {
  display: none;
  &:checked ~ main {
    transform: translateX($menu-width);
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console