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

              
                <html>
  <body>
  <header class="page-head">

    <a href="#" class="page-head__home-link"> </a>

    <a href="#" class="page-head__toggle"><span>Menu</span></a>
    <nav class="site-nav">
      <ul class="site-nav__list">
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 1</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 2</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Services</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 3</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 4</a></li>
        <li class="site-nav__item"><a href="#" class="site-nav__link">Link 5</a></li>
      </ul>
    </nav>

  </header>
</body>
  <div class="content">
    <h1>Heading</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  </div>
</html>

              
            
!

CSS

              
                
/**
 * Base.
 */
html {
	background: #222;
	font-size: 62.5%;
}

body {
	background-color: #fff;
  font-size: 16px;
  height: 1500px;
	margin: 110px 0 0;
	padding: 0;
	text-rendering: optimizeLegibility;
}

/**
 * Pace.js
 */

.page {
	opacity: 0;
	
	.pace-done & {
		opacity: 1;
		transition: opacity .5s ease;
	}
	
	.no-js & {
		opacity: 1 !important;
	}
}

/**
 * Progress bar styles.
 */

.pace {
  pointer-events: none;
  user-select: none;
}

.pace-inactive {
  display: none;
}

.pace .pace-progress {
	background: #a3cd39;
	height: 4px;
	position: fixed;
	top: 0;
	right: 100%;
	width: 100%;
	z-index: 2000;	
}





/**
 * Dummy Content.
 */

.content {
  margin: 0 auto;
  padding-top: 50px;
  max-width: 1000px;
}





/**
 * Header.
 */

.page-head__home-link {
  background: #fff;
	display: block;
	float: left;
  height: 52px;
	line-height: 0;
	margin-left: 2.5%;
	position: relative;
	transition: fill .25s;
	width: 140px;
	z-index: 2000;
}

.page-head {
	background: rgba(#222,0);
	box-sizing: border-box;
	height: 110px;
	overflow: hidden;
	padding-top: 30px;
	position: absolute;
	top: 0;
	right: 0;
  transform: translateY(0) translateZ(0);
	transition: background .10s, height .20s .20s, padding .20s .20s, transform .20s;
	width: 100%;
	z-index: 2000;
	
	&.invisible {
		opacity: 0;
		transform: translateY(-100%) translateZ(0);
		transition: transform .25s;
	}
	
	&.detached {
		background: #222;
		height: 70px;
		opacity: 1;
		padding-top: 10px;
		position: fixed;
	}
}


/**
 * Navigation.
 */

 .show-nav {
	 overflow: hidden;
 }

.site-nav {
	background: transparent;
	display: block;
	height: 100%;
	overflow: hidden;
	position: fixed;
	top: 0;
	text-align: center;
	transform: translate3d(0, 0, 0);
	transition: background .75s ease;
	user-select: none;
	visibility: hidden;
	width: 100%;
	z-index: -1;
	
	.show-nav & {
		background: rgba(#93b833,.98);
		overflow-y: auto;
		visibility: visible;
		z-index: 1000;
	}
	
	.hide-nav & {
		background: transparent;
		height: 100%;
		visibility: visible;
		width: 100%;
		z-index: 1000;
	}
}

.site-nav__list {
	margin: 0;
	padding: 0;
	position: absolute;
	top: 50%;
	left: 0%;
	transform: translateY(-50%);
	width: 100%;
}

.site-nav__item {
	margin: 0;
	opacity: 0;
	transform: translateY(-100px);
	transition: all .5s 0s cubic-bezier(0.68, -0.55, 0.265, 1.55);
	
	.show-nav & {
	    opacity: 1;
		  transform: translateY(0);
		  transition-delay: .25s;
		  transition-duration: 1s;
    }
}

.site-nav__link {
	background: transparent;
	color: #fff;
	display: block;
	font-size: 40px;
	line-height: 40px;
	font-style: italic;
	font-weight: 600;
	padding: 10px 0;
	transition: none;
	
	&:visited {
		background: transparent;
		color: #fff;
	}
	
	&:hover,
	&:focus {
		background: #fff;
		color: #93b833;
	}
}


/**
 * Toggle.
 */

.page-head__toggle {
	cursor: pointer;
	display: block;
	height: 55px;
	float: right;
	position: relative;
	right: 2.5%;
	text-indent: -9999px;
	transition: all .25s ease-in;
	width: 55px;
	-webkit-tap-highlight-color: rgba(0,0,0,0);
	-webkit-touch-callout: none;
	user-select: none;
	z-index: 9999999999999;
	
	&:focus {
		outline: none;
	}
	
	span {
		background: #93b833;
		display: block;
		height: 3px;
		position: absolute;
		top: 26px;
		right: 10px;
		left: 10px;
		
		&:before,
		&:after {
			background: #93b833;
			content: "";
			display: block;
			height: 3px;
			position: absolute;
			top: -8px;
			left: 0;
			width: 100%;	
		}
		
		&:after {
			top: auto;
			bottom: -8px;
		}
		
		.show-nav & {
			background: #fff;
			
			&:before,
			&:after {
				background: #fff;
			}
		}
	}
}


.page-head__toggle span {
  transition: background 0s .25s;
}

.page-head__toggle span:before,
.page-head__toggle span:after {
  transition-duration: .25s, .25s;
  transition-delay: .25s, 0s;
}

.page-head__toggle span:before {
  transition-property: top, transform;
}

.page-head__toggle span:after {
  transition-property: bottom, transform;
}

/* active state, i.e. menu open */

.show-nav {
	
	.page-head__toggle span {
	  background: none !important;
	}
	
	.page-head__toggle span:before {
	  top: 0;
	  transform: rotate(45deg);
	}
	
	.page-head__toggle span:after {
	  bottom: 0;
	  transform: rotate(-45deg);
	}
	
	.page-head__toggle span:before,
	.page-head__toggle span:after {
	  transition-delay: 0s, .25s;
	}
}
              
            
!

JS

              
                
/* #SHOW/HIDE HEADER */

$(document).ready(function(){
	
	var previousScroll = 0, // previous scroll position
	menuOffset = 70, // height of menu (once scroll passed it, menu is hidden)
	detachPoint = 220, // point of detach (after scroll passed it, menu is fixed)
	hideShowOffset = 5; // scrolling value after which triggers hide/show menu
	
	$(window).scroll(function() {
	    if (!$('.page-head').hasClass('expanded')) {
	        var currentScroll = $(this).scrollTop(), // gets current scroll position
	            scrollDifference = Math.abs(currentScroll - previousScroll); // calculates how fast user is scrolling
	
	        // if scrolled past menu
	        if (currentScroll > menuOffset) {
	            // if scrolled past detach point add class to fix menu
	            if (currentScroll > detachPoint) {
	                if (!$('.page-head').hasClass('detached'))
						$('.page-head').addClass('detached');
	            }
	
	            // if scrolling faster than hideShowOffset hide/show menu
	            if (scrollDifference >= hideShowOffset) {
	                if (currentScroll > previousScroll) {
	                    // scrolling down; hide menu
	                    if (!$('.page-head').hasClass('invisible'))
	                        $('.page-head').addClass('invisible');
	                } else {
	                    // scrolling up; show menu
	                    if ($('.page-head').hasClass('invisible'))
							$('.page-head').removeClass('invisible');
	                }
	            }
	        } else {
	            // only remove “detached” class if user is at the top of document (menu jump fix)
	            if (currentScroll <= 0) {
	                $('.page-head').removeClass('detached');
	            }
	        }
	
	        // If user is at the bottom of document show menu.
/*
	        if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
	            $('.page-head').removeClass('invisible');
	        }
*/
	
	        // Replace previous scroll position with new one.
	        previousScroll = currentScroll;
	    }
	});
});





/* #SHOW/HIDE NAVIGATION */
   
/* 
 * Creates classes to enable responsive navigation.
 */

// Wait for the DOM to be ready (all elements printed on page regardless if 
// loaded or not).
$(function(){

    // Bind a click event to anything with the class "toggle-nav".
    $('.page-head__toggle').click(function() {
	    if ($('body').hasClass('show-nav')) {
	        $('body').removeClass('show-nav').addClass('hide-nav');
	
	        setTimeout(function() {
	            $('body').removeClass('hide-nav');
	        }, 500);

	    } else {
	        $('body').removeClass('hide-nav').addClass('show-nav');
	    }
		// Deactivate the default behavior of going to the next page on click.
    	return false;
	});
});
              
            
!
999px

Console