cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <section class="hamburger-icons">
  
   <div class="container">

      <h1>Menu Icon Transitions</h1>
      
      <ul>
         
         <li>
            <button class="menu">
               <span class="hamburger hamburger1"></span>
               <span>Menu</span>
            </button>
         </li>
         
         <li>
            <button class="menu">
               <span class="hamburger hamburger2"></span>
               <span>Menu</span>
            </button>
         </li>
         
         <li>
            <button class="menu">
               <span class="hamburger hamburger3"></span>
               <span>Menu</span>
            </button>
         </li>
         
         <li>
            <button class="menu">
               <span class="hamburger hamburger4"></span>
               <span>Menu</span>
            </button>
         </li>
         
         <li>
            <button class="menu">
               <span class="hamburger hamburger5"></span>
               <span>Menu</span>
            </button>
         </li>
         
      </ul>

   </div>

</section>

<section class="plus-icons">
  
   <div class="container">

      <h1>Plus Icon Transitions</h1>
      
      <ul>
         
         <li>
            <button class="more more1"></button>
         </li>
         
         <li>
            <button class="more more2"></button>
         </li>
         
         <li>
            <button class="more more3"></button>
         </li>
         
         <li>
            <button class="more more4"></button>
         </li>
         
         <li>
            <button class="more more5"></button>
         </li>
         
      </ul>

   </div>

</section>
            
          
!
            
              // VARIABLES
$pink: #93073e;
$purple: #522f56;

// GENERAL
body {
   color: white;
   font-family: 'Josefin Sans', sans-serif;
   margin: 0
}

section {
   padding: 40px 0; 
   min-height: calc(50vh - 80px);
}

.hamburger-icons {
   background: $pink;
}

.plus-icons {
   background-color: $purple;
}

.container {
   max-width: 1200px;
   margin: 0 auto;
   padding: 0 20px;
}

h1 {
   font-size: 30px;
   text-align: center;
   
   @media all and (min-width: 800px) {
      font-size: 50px;
   }
}

ul {
   padding: 0;
   margin: 0;
   display: flex;
   flex-wrap: wrap;
   justify-content: space-between;
}

li {
   list-style-type: none;
   margin-bottom: 30px;
}

// TRANSITIONS
.bouncy-transition {
      transition: 0.2s ease-out all 0.2s;
      
   &:before, 
   &:after {
      transition: all .6s cubic-bezier(.46,-.41,.3,1.52) .1s;
   }
   
   .open-state & {
      transition: all .6s cubic-bezier(.46,-.41,.3,1.52) .1s;
      
      &:before, 
      &:after {
         transition: all .6s cubic-bezier(.46,-.41,.3,1.52) .1s;
      }
      
   }

}

button {
   position: relative;
   display: block;
   background: none;
   width: 100px;
   height: 100px;
   cursor: pointer;
   border: none;
   
   // Disabling any focus for illustration purposes. Important to have a focus state on buttons in production environments
   &:focus {
      outline: none;      
   }
   
}

.hamburger,
.more {
   display: block;
   margin: 0 auto;
   position: relative;
}

// MENU ICONS
.menu {

   // Hide Menu text but still make it accessible
   span:not(.hamburger) {
      display: block;
      position: absolute;
      clip: rect(1px, 1px, 1px, 1px);
   }

}

.hamburger {
   width: 100%;
   height: 10px;
   background: white;
   
   &:before, 
   &:after {
      content: "";
      position: absolute;
      width: 100%;
      border-bottom: 10px solid white;
      left: 0;
   }
   
   &:before {
      top: -25px;
   }
   
   &:after {
      top: 25px;
   }
   
   .open-state & {
      background: rgba(white, 0);
      
      &:before, 
      &:after {
         top: 50%;
      }
      
   }

}

.hamburger1 {
   @extend .bouncy-transition;
   
   .open-state & {
      
      &:before {
         transform: rotate(45deg);
      }
      
      &:after {
         transform: rotate(-45deg);
      }
      
   }
   
}

.hamburger2 {
   @extend .bouncy-transition;
   
   .open-state & {
      transform: rotate(-90deg);   
      
      &:before {
         transform: rotate(45deg);
      }
      
      &:after {
         transform: rotate(-45deg);
      }
      
   }
   
}

.hamburger3 {
   transition: 0.2s ease-out all 0.2s;
   
   &:before,
   &:after {
      transition: 0.2s top 0.2s, 0.2s transform;
   }
   
   .open-state & { 
      width: 50%;
      
      &:before, 
      &:after {
         transition: 0.2s top, 0.2s transform 0.2s;
      }
      
      &:before {
         transform: rotate(45deg);
      }
      
      &:after {
         transform: rotate(135deg);
      }
      
   }
   
}

.hamburger4 {
   @extend .bouncy-transition;
   
   .open-state & { 
      width: 50%;
      
      &:before {
         transform: rotate(-135deg);
      }
      
      &:after {
         transform: rotate(135deg);
      }
      
   }
   
}

.hamburger5 {
   @extend .bouncy-transition;
   
   .open-state & { 
      
      &:before {
         transform: rotate(-135deg);
         transition: 0.2s top 0.2s, 0.2s transform 0.4s;
      }
      
      &:after {
         transform: rotate(135deg);
         transition: 0.2s top, 0.2s transform 0.4s;
      }
      
   }
   
}

// PLUS ICONS
.more {
   @extend .bouncy-transition;
   
   &:before, 
   &:after {
      content: "";
      position: absolute;
      top: 50%;
      left: 50%;
      width: 90%;
      transform: translate(-50%, -50%);
      border-bottom: 10px solid white;
   }
   
   &:before {
      transform: translate(-50%, -50%) rotate(90deg);
   }
   
}

.more1 {
   
   .open-state & {
      
      &:before {
         transform: translate(-50%, -50%) rotate(180deg);
      }
      
      &:after {
         transform: translate(-50%, -50%) rotate(-180deg);
      }
   }
   
}

.more2 {
   
   .open-state & {
      
      &:before {
         transform: translate(-50%, -50%) rotate(135deg);
      }
      
      &:after {
         transform: translate(-50%, -50%) rotate(-135deg);
      }
   }
   
}

.more3 {
   
   &:after {
      transform: translate(-50%, -50%) rotate(180deg);
   }
   
   .open-state & {
      
      &:before {
         transform: translate(-50%, -50%) rotate(0);
      }
      
      &:after {
         transform: translate(-50%, -50%) rotate(0);
      }
   }
   
}

.more4 {
   
   &:before,
   &:after {
      transition: 0.2s width 0.2s, 0.2s transform;
   }
   
   .open-state & {
      
      &:before,
      &:after {
         width: 50%;
         transition: 0.2s width, 0.2s transform 0.2s;
      }
      
      &:before {
         transform: translate(-50%, -50%) rotate(-180deg);
      }
      
      &:after {
         transform: translate(-50%, -50%) rotate(180deg);
      }
   }
   
}

.more5 {
   
   .open-state & {
      
      &:before,
      &:after {
         width: 50%;
         margin-top: -5px;
      }
      
      &:before {
         transform: translate(0, 0) rotate(0);
      }
      
      &:after {
         left: 0;
         transform: translate(0, 0) rotate(-180deg);
      }
   }
   
}
            
          
!
            
              $('li').on('click', function() {
   
   $(this).toggleClass('open-state');
   
});
            
          
!
999px
Loading ..................

Console