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

              
                <button class="hamburger__toggle">
<span class="hamburger__icon"></span>
</button>
              
            
!

CSS

              
                body{
  background-color:black;
}

.hamburger__toggle{
  display:block;
  position: relative;
  background-color:#3d3d3d;
  width: 60px; 
  height: 60px; 
  margin:50px auto;
  border-radius:50%;
  border:none;
}

/* give the span element and related pseudo-elements the appearance of white lines */
.hamburger__icon,
.hamburger__icon::before,
.hamburger__icon::after {
  position: absolute;
  width: 30px; 
  height: 2px;
  border-radius: 4px;
  background-color: white;
}

/* center the span element in the middle of its containing button */
.hamburger__icon {
  top: calc(50% - 2px);
  left: calc(50% - 15px);
}

/* position the two pseudo-elements to the very left */
.hamburger__icon::before,
.hamburger__icon::after {
  content: "";
  left: 0;
}

/* this is the top dash of the hamburger */
.hamburger__icon::before {
  bottom: 8px;
}

/* this is the bottom dash of the hamburger */
.hamburger__icon::after {
  top: 8px;
}

/* TOGGLE STYLES FOR THE BUTTON */

/* rotate middle dash of hamburger */
.toggled .hamburger__icon {
  height: 5px;
  width: 54px;
  left: 5px;
  top: calc(50% - 2px);
  transform: rotate(-45deg);
  background-color: red;
}

/* rotate bottom dash of hamburger counter clockwise */
.toggled .hamburger__icon::after {
  width: 54px;
  height: 5px;
  top: -1px;
  transform: rotate(-270deg);
  background-color: red;
}

/* hide the top dash by scaling it to 0 */
.toggled .hamburger__icon::before {
  transform: scale(0);
}

/* TRANSITION */
/* adjust duration to see it happen slower */
.hamburger__icon, .hamburger__icon::after {
  transition: all 0.3s linear;
}
              
            
!

JS

              
                const button = document.querySelector(".hamburger__toggle");
button.addEventListener( "click", () => button.classList.toggle("toggled") );

              
            
!
999px

Console