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

              
                .container
  %h1 Menu Button to Hamburger
  %p.sub-title Styled & Animated With Pure CSS
  %button{} Menu
  %div.buttons
    %ol
      - 20.times do
        %li
          %button{:class => 'menu-toggle'} Menu
              
            
!

CSS

              
                @mixin flexbox {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

@mixin flex-vertical {
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-flow: column wrap;
  -ms-flex-flow: column wrap;
  flex-flow: column wrap;
  -webkit-justify-content: center;
  justify-content: center;
}

@mixin flex-horizontal {
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -webkit-flex-flow: row wrap;
  -ms-flex-flow: row wrap;
  flex-flow: row wrap;
  -webkit-justify-content: flex-start;
  justify-content: flex-start;
}

@mixin bgcolors($max-count) {
  $color: 360/$max-count;
  
  @for $i from 1 through $max-count {
    &:nth-child(#{$max-count}n + #{$i}):hover {
      
      $hue: ($i - 1)*$color;
      
      background: hsl($hue, 80%, 55%);
      
      @if $hue < 185 and $hue > 45 {
        color: #222;
      }
      @else {
        color: #FFF;
      }
    }
  }
}

.buttons * {
  padding: 0;
}

body {
  font: 100% Helvetica, sans-serif;
  color: #333;
  padding: 0;
  margin: 0;
  background: #F7F7F7;
  text-align: center;
}

h1,
p.sub-title {
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

h1,
.buttons {
  margin-top: 50px;
}

.buttons {
  ol {
    padding: 0;
    margin-left: 2.5vw;
    list-style: none;
    @include flexbox;
    @include flex-horizontal;
    
    li {
      position: relative;
      width: 23vw;
      height: 23vw;
      cursor: pointer;
      margin: 0 1vw 3vw 0;
      background: #FFF;
      transition: background 0.35s;
      counter-increment: list-counter;
      
      @include flexbox;
      @include flex-vertical;
      @include bgcolors(20);
      
      &:nth-child(4n) {
        margin-right: 0;
      }
      
      @media screen and (max-width : 768px) {
        & {
          width: 46vw;
          height: 46vw;
          margin: 0 4vw 4vw 0;
        }
        
        &:nth-child(2n) {
          margin-right: 0;
        }
      }
      
      &:before {
        position: absolute;
        bottom: 0;
        left: 0;
        z-index: -1;
        display: block;
        width: 23vw;
        height: 20vw;
        content: "";
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
      }
      
      &:after {
        position: absolute;
        top: 38%;
        right: 7vw;
        transform: rotate(-90deg);
        z-index: 1;
        display: block;
        width: 30px;
        height: 30px;
        text-align: center;
        content: counter(list-counter, decimal-leading-zero);
        font-family: Helvetica;
        font-size: 20px;
        line-height: 30px;
        font-weight: 300;
        opacity: 0.15;
        transition: color 0.35s;
        will-change: color;
      }
      
      button {
        position: relative;
        display: block;
        width: 50px;
        height: 1px;
        margin: 0 auto;
        border: none;
        cursor: pointer;
        background: currentColor;
        color: inherit;
        font-size: 0;
        transition: 0.35s;
        
        &:before,
        &:after {
          position: absolute;
          top: 0;
          left: 50%;
          display: block;
          width: 100%;
          height: 1px;
          background: currentColor;
          content: "";
          transition: transform 0.35s;
        }
        
        &:before {
          transform: translate(-50%, -14px);
        }
        
        &:after {
          transform: translate(-50%, 14px);
        }
      }
      
      &:nth-child(1) {
        button {
          &:before,
          &:after {
            transform-origin: 0% 0%;
          }
        }
        
        &:hover button {
          &:before {
            transform: translate(-50%, 0) rotate(-35deg) scaleX(0.6);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(35deg) scaleX(0.6);
          }
        }
      }
      
      &:nth-child(2) {
        button {
          &:before,
          &:after {
            transform-origin: 50% 0%;
          }
        }
      
        &:hover button {
          background: transparent;
          
          &:before {
            transform: translate(-50%, 0) rotate(45deg);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(-45deg);
          }
        }
      }
      
      &:nth-child(3) {
        button {
          &:before,
          &:after {
            transform-origin: 100% 0%;
          }
        }
      
        &:hover button {
          &:before {
            transform: translate(-50%, 0) rotate(35deg) scaleX(0.6);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(-35deg) scaleX(0.6);
          }
        }
      }
      
      &:nth-child(4) {
        button {
          &:before,
          &:after {
            transform-origin: 0% 0%;
          }
        }
      
        &:hover button {
          transform: rotate(-90deg);
          
          &:before {
            transform: translate(-50%, 0) rotate(-45deg) scaleX(0.8);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(45deg) scaleX(0.8);
          }
        }
      }
      
      &:nth-child(5) {
        button {
          &:before,
          &:after {
            transform-origin: 0% 0%;
          }
        }
      
        &:hover button {
          transform: rotate(90deg);
          
          &:before {
            transform: translate(-50%, 0) rotate(-45deg) scaleX(0.8);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(45deg) scaleX(0.8);
          }
        }
      }
      
      &:nth-child(6) {
        button {
          &:before,
          &:after {
            transform-origin: 0% 0%;
          }
        }
      
        &:hover button {
          background: transparent;
          
          &:before {
            transform: translate(-50%, 0) rotate(-45deg) scaleX(0.7);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(45deg) scaleX(0.7);
          }
        }
      }
      
      &:nth-child(7) {
        button {
          &:before,
          &:after {
            transform-origin: 100% 0%;
          }
        }
      
        &:hover button {
          background: transparent;
          
          &:before {
            transform: translate(-50%, 0) rotate(45deg) scaleX(0.7);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(-45deg) scaleX(0.7);
          }
        }
      }
      
      &:nth-child(8) {
        button {
          &:before,
          &:after {
            transform-origin: 100% 0%;
          }
        }
      
        &:hover button {
          transform: rotate(90deg);
          background: transparent;
          
          &:before {
            transform: translate(-50%, 0) rotate(45deg) scaleX(0.7);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(-45deg) scaleX(0.7);
          }
        }
      }
      
      &:nth-child(9) {
        button {
          transition: 0s;
          
          &:before,
          &:after {
            transform-origin: 50% 0%;
          }
        }
      
        &:hover button {
          background: transparent;
          
          &:before {
            animation: menuBefore 0.5s forwards;
          }
          
          &:after {
            animation: menuAfter 0.5s forwards;
          }
        }
      }
      
      @keyframes menuBefore {
        0% {
          transform: translate(-50%, -14px);
        }
        40% {
          transform: translate(-50%, 0);
        }
        60% {
          transform: translate(-50%, 0);
        }
        100% {
          transform: translate(-50%, 0) rotate(45deg);
        }
      }
      @keyframes menuAfter {
        0% {
          transform: translate(-50%, 14px);
        }
        40% {
          transform: translate(-50%, 0);
        }
        60% {
          transform: translate(-50%, 0);
        }
        100% {
          transform: translate(-50%, 0) rotate(-45deg);
        }
      }
      
      &:nth-child(10) {
        button {
          transition: transform 0.35s 0s;
          
          &:before,
          &:after {
            transform-origin: 0% 0%;
            transition: transform 0.35s 0.35s;
          }
        }
      
        &:hover button {
          transform: rotate(-90deg);
          transition: transform 0.35s 0.35s, background 0.35s 0s;
          
          &:before {
            transform: translate(-50%, 0) rotate(-45deg) scaleX(0.8);
            transition: transform 0.35s 0s;
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(45deg) scaleX(0.8);
            transition: transform 0.35s 0s;
          }
        }
      }
      
      &:nth-child(11) {
        button {
          transition: 0.1s;
          
          &:before,
          &:after {
            transform-origin: 100% 0%;
          }
          
          &:after {
            transition-delay: 0.15s;
          }
        }
      
        &:hover button {
          transform: translateX(8px);
          transition: transform 0.15s 0.5s;
          
          &:before {
            transform: translate(-50%, 0) rotate(35deg) scaleX(0.6);
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(-35deg) scaleX(0.6);
          }
        }
      }
      
      &:nth-child(12) {
        button {
          transition: transform 0.35s 0.35s;
          
          &:before,
          &:after {
            transform-origin: 0% 0%;
            transition: transform 0.35s 0s;
          }
        }
      
        &:hover button {
          transform: rotate(-90deg);
          transition: transform 0.35s 0s;
          
          &:before {
            transform: translate(-50%, 0) rotate(-45deg) scaleX(0.8);
            transition: transform 0.35s 0.35s;
          }
          
          &:after {
            transform: translate(-50%, 0) rotate(45deg) scaleX(0.8);
            transition: transform 0.35s 0.35s;
          }
        }
      }
      
      
      &:nth-child(n+13) {
        & button {
          height: 30px;
          background: transparent;
          border-top: 1px solid;
          border-bottom: 1px solid;
          
          &:before,
          &:after {
            top: 50%;
            transform: translate(-50%, -50%);
          }
        }
      }
      
      &:nth-child(13) {
        &:hover button {
          border-color: transparent;
          
          &:before {
            transform: translate(-50%, -50%) rotate(45deg);
          }
          
          &:after {
            transform: translate(-50%, -50%) rotate(-45deg);
          }
        }
      }
      
      &:nth-child(14) {
        &:hover button {
          border-color: transparent;
          
          &:before {
            transform: translate(-50%, -50%) rotate(-45deg);
          }
          
          &:after {
            transform: translate(-50%, -50%) rotate(-135deg);
          }
        }
      }
      
      &:nth-child(15) {
        &:hover button {
          border-color: transparent;
          
          &:before {
            transform: translate(-50%, -50%) rotate(135deg);
          }
          
          &:after {
            transform: translate(-50%, -50%) rotate(-135deg);
          }
        }
      }
      
      &:nth-child(16) {
        button {
          &:before,
          &:after {
            transform-origin: 100% 0%;
          }
        }
      
        &:hover button {
          border-color: transparent;
          
          &:before {
            transform: translate(-50%, -50%) rotate(30deg) scaleX(0.7);
          }
          
          &:after {
            transform: translate(-50%, -50%) rotate(-30deg) scaleX(0.7);
          }
        }
      }
      
      &:nth-child(17) {
        button {
          transition: height 0.35s 0.35s, border-color 0.35s 0.35s;
          
          &:before,
          &:after {
            transform-origin: 50% 50%;
          }
        }
      
        &:hover button {
          height: 0;
          border-color: transparent;
          transition: all 0.35s 0s;
          
          &:before {
            transform: translate(-50%, -50%) rotate(45deg);
            transition-delay: 0.5s;
          }
          
          &:after {
            transform: translate(-50%, -50%) rotate(-45deg);
            transition-delay: 0.5s;
          }
        }
      }
      
      &:nth-child(18) {
        button {
          transition: height 0.35s 0.35s, border-color 0.35s 0.35s;
          
          &:before,
          &:after {
            transform-origin: 50% 50%;
          }
        }
      
        &:hover button {
          height: 0;
          border-color: transparent;
          transition: all 0.35s 0s;
          
          &:before {
            transform: translate(-50%, -50%) rotate(-45deg);
            transition-delay: 0.5s;
          }
          
          &:after {
            transform: translate(-50%, -50%) rotate(-135deg);
            transition-delay: 0.5s;
          }
        }
      }
      
      &:nth-child(19) {
        button {
          transition: height 0.35s 0.35s, border-color 0.35s 0.35s, transform 0.35s 0s;
          
          &:before,
          &:after {
            transform-origin: 50% 50%;
          }
        }
      
        &:hover button {
          height: 0;
          border-color: transparent;
          transform: rotate(135deg);
          transition: all 0.35s 0s, transform 0.35s 1s;
          
          &:before {
            transform: translate(-50%, -50%) rotate(90deg);
            transition-delay: 0.5s;
          }
        }
      }
      
      &:nth-child(20) {
        button {
          transition: height 0.35s 0.35s, border-color 0.35s 0.35s, transform 0.35s 0s;
          
          &:before,
          &:after {
            transform: translate(0, -50%);
            width: 50%;
            height: 0;
            background: transparent;
            border-top: 1px solid;
          }
          
          &:before {
            left: 0;
            border-right: 1px solid;
          }
          
          &:after {
            left: auto;
            right: 0;
            border-left: 1px solid;
          }
        }
      
        &:hover button {
          height: 0;
          border-color: transparent;
          transform: rotate(360deg);
          transition: all 0.35s 0s, transform 0.7s 0s;
          
          &:before,
          &:after {
            height: 25px;
            transition: height 0.35s 0.35s, transform 0.35s 0.35s;
          }
          
          &:before {
            transform: translate(-6px, -50%) rotate(45deg);
          }
          &:after {
            transform: translate(6px, -50%) rotate(-45deg);
          }
        }
      }
    }
    
    &:after {
      display: block;
      clear: both;
      content: "";
      position: relative;
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console