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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <div class="phone">
  
  <!-- Menu Button-->
  <span id="menu-button">
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  x="0px" y="0px" width="40px" height="32.1px" viewBox="0 0 40 32.1" style="enable-background:new 0 0 40 32.1;" xml:space="preserve">
        <path id="menu1" d="M38.6,2.9H1.4C0.6,2.9,0,2.2,0,1.4S0.6,0,1.4,0h37.2C39.4,0,40,0.6,40,1.4S39.4,2.9,38.6,2.9z"/>
        <path id="menu2" d="M24.1,13.1H1.4c-0.8,0-1.4-0.6-1.4-1.4c0-0.8,0.6-1.4,1.4-1.4h22.7c0.8,0,1.4,0.6,1.4,1.4C25.5,12.5,24.8,13.1,24.1,13.1z" />
        <path id="menu3" d="M38.6,23.4H1.4c-0.8,0-1.4-0.6-1.4-1.4c0-0.8,0.6-1.4,1.4-1.4h37.2c0.8,0,1.4,0.6,1.4,1.4C40,22.7,39.4,23.4,38.6,23.4z"/>
        <path id="menu4" d="M24.1,32.1H1.4c-0.8,0-1.4-0.6-1.4-1.4c0-0.8,0.6-1.4,1.4-1.4h22.7c0.8,0,1.4,0.6,1.4,1.4C25.5,31.4,24.8,32.1,24.1,32.1z" />
    </svg>
  </span>
  
  <!-- Menu Content -->
  <div id="menu">
	  <ul>
		  <li>Froot Loops</li>
		  <li>Frosted Flakes</li>
		  <li>Cheerios</li>
		  <li>Cap'n Crunch</li>
	  </ul>
  </div>
  
  <!-- Page Content -->
  <div class="content">
    <h1>What are the most delicious cereals ?</h1>
  </div>
  
</div>
            
          
!
            
              /* Demo Default Styling */
body {
  background: DodgerBlue;
  padding: 20px;
}

.phone {
  background: LightGray;
  width: 320px;
  height: 480px;
  margin: auto;
  border-radius: 5px;
  border: solid 10px Gainsboro;
  position: relative;
  overflow: hidden;
}

.content {
  padding: 0 30px;
  height: 100%;
  position: relative;
  
  h1 {
    color: Crimson;
    font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
    text-align: center;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
  }
  
}

/* Hamburger Menu Styling */
#menu-button {
    background: none;
    border-radius: 30px;
		width: 47px;
		height: 47px;
		display: block;
    transition: 0.5s;
    position: absolute;
    margin: 10px;
    z-index: 2;

		svg {
			width: 30px;
      margin-top: 3px;
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
      
      path {
        fill: white;
      }

			#menu1 {
				animation: 0.65s linear 0s normal none animateCM1;
				animation-fill-mode: forwards;
			}

			#menu2 {
				animation: 0.65s linear 0s normal none animateCM2;
				animation-fill-mode: forwards;
			}

			#menu3 {
				animation: 0.65s linear 0s normal none animateCM3;
				animation-fill-mode: forwards;
			}

			#menu4 {
				animation: 0.65s linear 0s normal none animateCM4;
				animation-fill-mode: forwards;
			}

		}

		&.menu-opened {
      background: #e53d5f;
      border-radius: 30px;

			svg {

				#menu1 {
					animation: 0.65s linear 0s normal none animateM1;
					animation-fill-mode: forwards;
				}

				#menu2 {
					animation: 0.65s linear 0s normal none animateM2;
					animation-fill-mode: forwards;
				}

				#menu3 {
					animation: 0.65s linear 0s normal none animateM3;
					animation-fill-mode: forwards;
				}

				#menu4 {
					animation: 0.65s linear 0s normal none animateM4;
					animation-fill-mode: forwards;
				}

			}

	}

}

#menu {
  height: 0;
  overflow: hidden;
  position: relative;
  transition: 0.5s;
  width: 100%;
  z-index: 1;
  
  ul {
    color: white;
    font-family: Arial, sans-serif;
    list-style-type: none;
    padding: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  
  li {
    margin: 0 0 20px;
    text-transform: uppercase;
    opacity: 0;
    text-align: center;
    
    &:last-child {
      margin: 0;
    }
    
  }
  
  &.active {
    height: 480px;
    background: Crimson;
    position: relative;
    top: 0;
    left: 0;
    
    li {
      margin: 0 0 20px;
      text-transform: uppercase;
      opacity: 0;
      animation: fadeIn 0.9s 1;
      animation-fill-mode: forwards;

      &:nth-child(5n+1) {
        animation-delay: 0.5s;
      }

      &:nth-child(5n+2) {
        animation-delay: 1.0s;
      }

      &:nth-child(5n+3) {
        animation-delay: 1.5s;
      }

      &:nth-child(5n+4) {
        animation-delay: 2.0s;
      }

      &:last-child {
        margin: 0;
      }

    }
    
  }
  
}

// Open Menu Button Animation
@keyframes animateM1 {
	0% {transform-origin: center center;transform: translate(0, 0);}
	25% {transform-origin: center center;transform: translate(0, 0);}
	50% {transform-origin: center center;transform: translate(0, 14px);}
	75% {transform-origin: center center;transform: translate(0px, 12px) rotate(45deg); -moz-transform: translate(-10px, 6px) rotate(45deg);}
	100% {transform-origin: center center;transform: translate(0px, 12px) rotate(45deg); -moz-transform: translate(-10px, 6px) rotate(45deg);}
}

@keyframes animateM2 {
	0% {transform: translate(0, 0); opacity: 1;}
	25% {transform: translate(8px, 0); opacity: 1;}
	50% {transform: translate(8px, 5px); opacity: 0;}
	75% {transform: translate(8px, 5px); opacity: 0;}
	100% {transform: translate(8px, 5px); opacity: 0;}
}

@keyframes animateM3 {
	0% {transform-origin: center center;transform: translate(0, 0);}
	25% {transform-origin: center center;transform: translate(0, 0);}
	50% {transform-origin: center center;transform: translate(0, -6px);}
	75% {transform-origin: center center;transform: translate(-2px, -8px) rotate(-45deg);-moz-transform: translate(-5px, -8px) rotate(-45deg);}
	100% {transform-origin: center center;transform: translate(-2px, -8px) rotate(-45deg);-moz-transform: translate(-5px, -8px) rotate(-45deg);}
}

@keyframes animateM4 {
	0% {transform: translate(0, 0); opacity: 1;}
	25% {transform: translate(8px, 0); opacity: 1;}
	50% {transform: translate(8px, -14px); opacity: 0;}
	75% {transform: translate(8px, -14px); opacity: 0;}
	100% {transform: translate(8px, -14px); opacity: 0;}
}


// Close Menu Button Animation
@keyframes animateCM1 {
	100% {transform-origin: center center;transform: translate(0, 0);}
	75% {transform-origin: center center;transform: translate(0, 0);}
	50% {transform-origin: center center;transform: translate(0, 14px);}
	25% {transform-origin: center center;transform: translate(0px, 12px) rotate(45deg);-moz-transform: translate(-10px, 6px) rotate(45deg);}
	0% {transform-origin: center center;transform: translate(0px, 12px) rotate(45deg);-moz-transform: translate(-10px, 6px) rotate(45deg);}
}

@keyframes animateCM2 {
	100% {transform: translate(0, 0); opacity: 1;}
	75% {transform: translate(8px, 0); opacity: 1;}
	50% {transform: translate(8px, 5px); opacity: 0;}
	25% {transform: translate(8px, 5px); opacity: 0;}
	0% {transform: translate(8px, 5px); opacity: 0;}
}

@keyframes animateCM3 {
	100% {transform-origin: center center;transform: translate(0, -1px);}
	75% {transform-origin: center center;transform: translate(0, 0);}
	50% {transform-origin: center center;transform: translate(0, -6px);}
	25% {transform-origin: center center;transform: translate(-2px, -8px) rotate(-45deg);-moz-transform: translate(-5px, -8px) rotate(-45deg);}
	0% {transform-origin: center center;transform: translate(-2px, -8px) rotate(-45deg);-moz-transform: translate(-5px, -8px) rotate(-45deg);}
}

@keyframes animateCM4 {
	100% {transform: translate(0, 0); opacity: 1;}
	75% {transform: translate(8px, 0); opacity: 1;}
	50% {transform: translate(8px, -14px); opacity: 0;}
	25% {transform: translate(8px, -14px); opacity: 0;}
	0% {transform: translate(8px, -14px); opacity: 0;}
}


// Menu List Fade In
@keyframes fadeIn {
  0% {opacity: 0.0;}
  100% {opacity: 1.0;}
}
            
          
!
            
              // Toggle Function
function toggleClass(element, className){
    if (!element || !className){
        return;
    }
    
    var classString = element.className, nameIndex = classString.indexOf(className);
    if (nameIndex == -1) {
        classString += ' ' + className;
    }
    else {
        classString = classString.substr(0, nameIndex) + classString.substr(nameIndex+className.length);
    }
    element.className = classString;
}

// Button Click
document.getElementById('menu-button').addEventListener('click', function() {
    toggleClass(document.getElementById('menu-button'), 'menu-opened');
    toggleClass(document.getElementById('menu'), 'active');
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console