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. 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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="menu-toggle">
  Menu
</div><!-- .menu-toggle -->
              
            
!

CSS

              
                //-----------------------------------------
// Global Elements — Not for Demo
//-----------------------------------------
body {
	height: 100vh;
	position: relative;
} // body

//-----------------------------------------
// Make the Hamburger Icon
//-----------------------------------------
@mixin generate_hamburger($width, $height, $space, $color, $position, $radius, $speed) {
	
	// Start variables.
	$gutter: $height + $space;
	
	 // Determine position left right or center.
	@if $position==right {
		float: right;
	}
	
	@else if $position==left {
		float: left;
	}
	@else {
		margin-left: auto;
		margin-right: auto;
	}
	
	margin-bottom: $height + $space;
	margin-top: $height + $space;
	position: relative;
	text-indent: -9999em;
	
	// All bar sizes.
	&,
	&::before,
	&::after {
		background-color: $color;
		
		// Border radius?
		@if $radius !=0 {
			border-radius: $radius;
		}
		height: $height;
		transition: all $speed ease-in-out;
		width: $width;
	} // &, &::before, &::after
	
	// Top/bottom bars.
	&::before,
	&::after {
		content: "";
		left: 0;
		position: absolute;
	} // &::before, &::after
	
	// Top bar.
	&::before {
		top: -$gutter;
	} // &::before
	
	// Bottom bar.
	&::after {
		bottom: -$gutter;
	} // &::after
	
	// Active state.
	&.is-active {
		@include activate_hamburger(#675aac);
	} // &.is-active
} // generate_hamburger

// If active.
@mixin activate_hamburger($color) {
	& {
		background-color: transparent;
	} // &

	// Top/bottom bars.
	&::before,
	&::after {
		background-color: $color;
	} // &::before, &::after

	// Top bar.
	&::before {
		top: -1px;
		transform: rotate(45deg);
	} // &::before

	// Bottom bar.
	&::after {
		bottom: 1px;
		transform: rotate(-45deg);
	} // &::after
}

//-----------------------------------------
//  Make it go — Toggle it up!
//-----------------------------------------
.menu-toggle {
	@include generate_hamburger(30px, 5px, 5px, #000, null, 5px, 0.3s);
	
	// Just for codepen.
	left: 50%;
	margin-top: -13px;
	position: absolute;
	top: 50%;
} // .menu-toggle
              
            
!

JS

              
                // Adds class when menu-toggle is clicked
$(document).ready(function () {
  
  // Global elements
  var $toggle = $('.menu-toggle');
  
  // On click toggle class.
  $toggle.on( 'click', function() {
    var $this = $( this );
    
    // Toggle .is-active.
    $this.toggleClass( 'is-active' );
  });
});
              
            
!
999px

Console