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 class="nav__bar">
  <input type="checkbox" id="toggle" aria-hidden="true" />
  <label for="toggle" class="nav__icon" aria-hidden="true">
    Expand the menu
    <span class="nav__icon-line"></span>
    <span class="nav__icon-line"></span>
    <span class="nav__icon-line"></span>
  </label>
  <nav role="navigation" class="nav">
    <ul class="nav__items">
      <li class="nav__item"><a href="#">Item 1</a></li>
      <li class="nav__item"><a href="#">Item 2</a></li>
      <li class="nav__item"><a href="#">Item 3</a></li>
    </ul>
  </nav>
</div>

<h1>Pure CSS hamburger menu (accessible)</h1>
<p>
  Resize the browser to see the hamburger menu. This approach uses the checkbox hack to allow CSS to handle the hamburger toggle. The menu items will be accessible to screenreaders even when hidden.
</p>
<p>
  Inspired by <a href="https://codepen.io/bloom-dan/pen/vKdoar">https://codepen.io/bloom-dan/pen/vKdoar</a>
</p>
              
            
!

CSS

              
                // Variables
$breakpoint: 900px;
$green: #86973a;
$nav-height: 60px;

* {
  font-family: Helvetica, sans-serif;
  box-sizing: border-box;
}

.nav {

  &__bar {
    background-color: $green;
    padding-top: $nav-height;
    position: relative;

    @media (min-width: $breakpoint) {
      padding-top: 0;
    }
  }

  &__items {
    max-height: 1px; //0 would hide from screen readers
    overflow: hidden;
    list-style: none;
    margin: 0;
    padding: 0;
    transition: all 1s cubic-bezier(.325, 1, .22, 1);

    @media (min-width: $breakpoint) {
      max-height: none;
      text-align: center;
    }
  }

  &__item {
    padding: 0;
    margin: 0;
    background: #fff;

    @media (min-width: $breakpoint) {
      display: inline-block;
    }

    a {
      display: block;
      padding: 1em;
      margin: 0;
      border-bottom: 1px solid #fff;
      color: #fff;
      background: $green;
      font-size: 1.2rem;
      text-decoration: none;
      transition: opacity 0.5s ease;

      @media (min-width: $breakpoint) {
        display: inline-block;
        height: $nav-height;
        line-height: $nav-height;
        padding-top: 0;
        padding-bottom: 0;
        border: none;
      }

      &:link,
      &:visited {
        color: #fff;
      }

      &:hover,
      &:focus {
        text-decoration: none;
        opacity: 0.7;
      }
    }
  }

  &__icon {
    display: block;
    position: absolute;
    top: ($nav-height - 20px) / 2;
    right: 13px;
    height: 27px;
    width: 27px;
    cursor: pointer;
    text-indent: -9999px; //Hide the label
    transition: all 1s cubic-bezier(.19, 1, .22, 1);

    //Remove blinking cursor
    border: none;
    color: transparent;
    text-shadow: 0 0 0 gray;
    text-align: center;

    &:focus {
        outline: none;
    }

    @media (min-width: $breakpoint) {
      display: none;
    }
  }

  &__icon-line {
    position: absolute;
    display: block;
    background: #fff;
    width: 27px;
    height: .2rem;
    border-radius: .2rem;
    left: 0;
    text-indent: 0;
    transition: all .6s cubic-bezier(.5, .1, 0, 1.2);

    &:first-child {
      top: 0;
    }

    &:nth-child(2) {
      top: 8px;
    }

    &:nth-child(3) {
      top: 16px;
    }
  }
}

// Checkbox hack for toggling mobile menu
input[type=checkbox] {
  display: none;
  visibility: hidden;

  &:checked {

    ~ nav .nav__items {
      height: auto;
      max-height: 30rem;
      transition: all 2s cubic-bezier(.5, 1, .22, 1);
    }

    ~ label .nav__icon-line:first-child {
      top: 0px;
      width: 27px;
      transform: translateX(-8px) rotate(-45deg) translateY(12px);
    }

    ~ label .nav__icon-line:nth-child(2) {
      opacity: 0;
    }

    ~ label .nav__icon-line:nth-child(3) {
      top: 14px;
      width: 27px;
      transform: translateX(-5px) rotate(45deg) translateY(-8px);
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console