Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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="line">
  <button class="c-hamburger c-hamburger--rot">
  <span>toggle menu</span>
</button>

<button class="c-hamburger c-hamburger--htx">
  <span>toggle menu</span>
</button>

<button class="c-hamburger c-hamburger--htla">
  <span>toggle menu</span>
</button>

<button class="c-hamburger c-hamburger--htra">
  <span>toggle menu</span>
</button>

<button class="c-hamburger c-hamburger--htta">
  <span>toggle menu</span>
</button>
  
 <button class="c-hamburger c-hamburger--htba">
  <span>toggle menu</span>
</button>
</div>
  <div class="author"><p><a href="http://callmenick.com/post/animating-css-only-hamburger-menu-icons"> &copy original material, where I forked and upgraded to this state</a>
</div>

              
            
!

CSS

              
                html, body {
  background: #333;
  display: flex;
  flex-direction: column;
    justify-content: center;
    align-self: center;
    align-content: center;
}

.line {
  position: relative;
  clear: both;
  width: 100%;
  height: 150px;
  display: inline-flex;
    justify-content: center;
    align-self: center;
    align-content: center;
}
.author {
  position: relative;
 width: 100%;
  height: 20px;
    display: flex;
    justify-content: center;
    align-self: center;
    align-content: center;
}

.author a {
  color: #fff;
}

.c-hamburger {
  display: block;
  position: relative;
  overflow: hidden;
  margin: 0;
  padding: 0;
  width: 96px;
  height: 96px;
  font-size: 0;
  text-indent: -9999px;
  appearance: none;
  box-shadow: none;
  border-radius: none;
  border: none;
  cursor: pointer;
  transition: background 0.3s;
}

.c-hamburger:focus {
  outline: none;
}

.c-hamburger span {
  display: block;
  position: absolute;
  top: 44px;
  left: 18px;
  right: 18px;
  height: 8px;
  background: white;
}

.c-hamburger span::before,
.c-hamburger span::after {
  position: absolute;
  display: block;
  left: 0;
  width: 100%;
  height: 8px;
  background-color: #fff;
  content: "";
}

.c-hamburger span::before {
  top: -20px;
}

.c-hamburger span::after {
  bottom: -20px;
}

/*haburger rotation*/

.c-hamburger--rot {
  background-color: #28aadc;
}

.c-hamburger--rot span {
  transition: transform 0.3s;
}

/* active state, i.e. menu open */
.c-hamburger--rot.is-active {
  background-color: #166888;
}

.c-hamburger--rot.is-active span {
  transform: rotate(90deg);
}

/*hamburger to x*/

.c-hamburger--htx {
  background-color: #ff3264;
}

.c-hamburger--htx span {
  
  transition: background 0s 0.3s;
}

.c-hamburger--htx span::before,
.c-hamburger--htx span::after {
  transition-duration: 0.3s, 0.3s;
  transition-delay: 0.3s, 0s;
}

.c-hamburger--htx span::before {
  transition-property: top, transform;
}

.c-hamburger--htx span::after {
  transition-property: bottom, transform;
}

/* active state, i.e. menu open */
.c-hamburger--htx.is-active {
  background-color: #cb0032;
}

.c-hamburger--htx.is-active span {
  background: none;
}

.c-hamburger--htx.is-active span::before {
  top: 0;
  transform: rotate(45deg);
}

.c-hamburger--htx.is-active span::after {
  bottom: 0;
  transform: rotate(-45deg);
}

.c-hamburger--htx.is-active span::before,
.c-hamburger--htx.is-active span::after {
  transition-delay: 0s, 0.3s;
}

/*hamburger to left arrow*/

.c-hamburger--htla {
  background-color: #32dc64;
}

.c-hamburger--htla span {
  transition: transform 0.3s;
}

.c-hamburger--htla span::before {
  transform-origin: top right;
  transition: transform 0.3s, width 0.3s, top 0.3s;
}

.c-hamburger--htla span::after {
  transform-origin: bottom right;
  transition: transform 0.3s, width 0.3s, bottom 0.3s;
}

/* active state, i.e. menu open */
.c-hamburger--htla.is-active {
  background-color: #18903c;
}

.c-hamburger--htla.is-active span {
  transform: rotate(-180deg);
}

.c-hamburger--htla.is-active span::before,
.c-hamburger--htla.is-active span::after {
  width: 50%;
}

.c-hamburger--htla.is-active span::before {
  top: 0;
  transform: translateX(38px) translateY(4px) rotate(45deg);
}

.c-hamburger--htla.is-active span::after {
  bottom: 0;
  transform: translateX(38px) translateY(-4px) rotate(-45deg);
}

/*hamburger to right arrow*/

.c-hamburger--htra {
  background-color: #ff9650;
}

.c-hamburger--htra span {
  transition: transform 0.3s;
}

.c-hamburger--htra span::before {
  transform-origin: top left;
  transition: transform 0.3s, width 0.3s, top 0.3s;
}

.c-hamburger--htra span::after {
  transform-origin: bottom left;
  transition: transform 0.3s, width 0.3s, bottom 0.3s;
}

/* active state, i.e. menu open */
.c-hamburger--htra.is-active {
  background-color: #e95d00;
}

.c-hamburger--htra.is-active span {
  transform: rotate(180deg);
}

.c-hamburger--htra.is-active span::before,
.c-hamburger--htra.is-active span::after {
  width: 50%;
}

.c-hamburger--htra.is-active span::before {
  top: 0;
  transform: translateX(-8px) translateY(4px) rotate(-45deg);
}

.c-hamburger--htra.is-active span::after {
  bottom: 0;
  transform: translateX(-8px) translateY(-4px) rotate(45deg);
}

/*hamburger to top arrow*/

.c-hamburger--htta {
  background-color: #50ff90;
}

.c-hamburger--htta span {
  transition: transform 0.3s;
}

.c-hamburger--htta span::before {
  transform-origin: top left;
  transition: transform 0.3s, width 0.3s, top 0.3s;
}

.c-hamburger--htta span::after {
  transform-origin: bottom left;
  transition: transform 0.3s, width 0.3s, bottom 0.3s;
}

/* active state, i.e. menu open */
.c-hamburger--htta.is-active {
  background-color: #ff9090;
}

.c-hamburger--htta.is-active span {
  transform: rotate(90deg);
}

.c-hamburger--htta.is-active span::before,
.c-hamburger--htta.is-active span::after {
  width: 50%;
}

.c-hamburger--htta.is-active span::before {
  top: 0;
  transform: translateX(-8px) translateY(4px) rotate(-45deg);
}

.c-hamburger--htta.is-active span::after {
  bottom: 0;
  transform: translateX(-8px) translateY(-4px) rotate(45deg);
}

/* hamburger to bottom arrow */


.c-hamburger--htba {
  background-color: #4030ff;
}

.c-hamburger--htba span {
  transition: transform 0.3s;
}

.c-hamburger--htba span::before {
  transform-origin: top left;
  transition: transform 0.3s, width 0.3s, top 0.3s;
}

.c-hamburger--htba span::after {
  transform-origin: bottom left;
  transition: transform 0.3s, width 0.3s, bottom 0.3s;
}

/* active state, i.e. menu open */
.c-hamburger--htba.is-active {
  background-color: #9030ff;
}

.c-hamburger--htba.is-active span {
  transform: rotate(-90deg);
}

.c-hamburger--htba.is-active span::before,
.c-hamburger--htba.is-active span::after {
  width: 50%;
}

.c-hamburger--htba.is-active span::before {
  top: 0;
  transform: translateX(-8px) translateY(4px) rotate(-45deg);
}

.c-hamburger--htba.is-active span::after {
  bottom: 0;
  transform: translateX(-8px) translateY(-4px) rotate(45deg);
}
              
            
!

JS

              
                (function() {

  "use strict";

  var toggles = document.querySelectorAll(".c-hamburger");

  for (var i = toggles.length - 1; i >= 0; i--) {
    var toggle = toggles[i];
    toggleHandler(toggle);
  };

  function toggleHandler(toggle) {
    toggle.addEventListener( "click", function(e) {
      e.preventDefault();
      (this.classList.contains("is-active") === true) ? this.classList.remove("is-active") : this.classList.add("is-active");
    });
  }

})();
              
            
!
999px

Console