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

              
                <header role="banner">
	<div class="wrapper">
		<nav class="navbar" role="navigation" aria-label="main navigation">
			<a class="navbar_brand-logo" href="#" title="Logo" alt="Visit Homepage" rel="home" aria-label="comapny brand logo">
				<svg width="150" height="70" viewBox="0 0 150 70" fill="none" xmlns="http://www.w3.org/2000/svg">
					<path d="M0 0H150V70H0V0Z" fill="#EBE8E8" />
					<path d="M34.209 24.1279H38.5703V41.2476H48.9072V45H34.209V24.1279Z" fill="black" />
					<path d="M61.1699 41.8848C62.8975 41.8848 64.2663 41.2476 65.2764 39.9731C66.2959 38.6987 66.8057 36.8862 66.8057 34.5356C66.8057 32.1945 66.2959 30.3867 65.2764 29.1123C64.2663 27.8285 62.8975 27.1865 61.1699 27.1865C59.4424 27.1865 58.0641 27.8237 57.0352 29.0981C56.0062 30.3726 55.4917 32.1851 55.4917 34.5356C55.4917 36.8862 56.0062 38.6987 57.0352 39.9731C58.0641 41.2476 59.4424 41.8848 61.1699 41.8848ZM71.167 34.5356C71.167 38.2834 70.1144 41.1532 68.0093 43.145C66.4328 44.7687 64.153 45.5806 61.1699 45.5806C58.1868 45.5806 55.9071 44.7687 54.3306 43.145C52.216 41.1532 51.1587 38.2834 51.1587 34.5356C51.1587 30.7124 52.216 27.8426 54.3306 25.9263C55.9071 24.3026 58.1868 23.4907 61.1699 23.4907C64.153 23.4907 66.4328 24.3026 68.0093 25.9263C70.1144 27.8426 71.167 30.7124 71.167 34.5356Z" fill="black" />
					<path d="M88.5415 30.6416C88.2111 29.2161 87.404 28.2202 86.1201 27.6538C85.4027 27.3423 84.605 27.1865 83.7271 27.1865C82.0467 27.1865 80.6637 27.8237 79.5781 29.0981C78.502 30.3631 77.9639 32.27 77.9639 34.8188C77.9639 37.3866 78.5492 39.2038 79.7197 40.2705C80.8903 41.3372 82.2214 41.8706 83.7129 41.8706C85.1761 41.8706 86.375 41.4505 87.3096 40.6104C88.2441 39.7607 88.82 38.6515 89.0371 37.2827H84.2085V33.7993H92.9028V45H90.0142L89.5752 42.3945C88.735 43.3857 87.9798 44.0843 87.3096 44.4902C86.1579 45.1982 84.7419 45.5522 83.0615 45.5522C80.2956 45.5522 78.0299 44.5941 76.2646 42.6777C74.4238 40.752 73.5034 38.1182 73.5034 34.7764C73.5034 31.3968 74.4333 28.6875 76.293 26.6484C78.1527 24.6094 80.6118 23.5898 83.6704 23.5898C86.3231 23.5898 88.4518 24.2648 90.0566 25.6147C91.6709 26.9552 92.596 28.6309 92.832 30.6416H88.5415Z" fill="black" />
					<path d="M106.312 41.8848C108.04 41.8848 109.409 41.2476 110.419 39.9731C111.438 38.6987 111.948 36.8862 111.948 34.5356C111.948 32.1945 111.438 30.3867 110.419 29.1123C109.409 27.8285 108.04 27.1865 106.312 27.1865C104.585 27.1865 103.207 27.8237 102.178 29.0981C101.149 30.3726 100.634 32.1851 100.634 34.5356C100.634 36.8862 101.149 38.6987 102.178 39.9731C103.207 41.2476 104.585 41.8848 106.312 41.8848ZM116.31 34.5356C116.31 38.2834 115.257 41.1532 113.152 43.145C111.575 44.7687 109.296 45.5806 106.312 45.5806C103.329 45.5806 101.05 44.7687 99.4731 43.145C97.3586 41.1532 96.3013 38.2834 96.3013 34.5356C96.3013 30.7124 97.3586 27.8426 99.4731 25.9263C101.05 24.3026 103.329 23.4907 106.312 23.4907C109.296 23.4907 111.575 24.3026 113.152 25.9263C115.257 27.8426 116.31 30.7124 116.31 34.5356Z" fill="black" />
				</svg>
			</a>
			<button class="hamburger" aria-expanded="false" aria-controls="nav" aria-haspopup="true">
				<span class="line"></span>
				<span class="line"></span>
				<span class="line"></span>
			</button>
			<ul id="menu" class="nav" aria-label="menu">
				<li><a href="#">Page One</a></li>
				<li><a href="#">Page Two</a></li>
				<li class="menu-item-has-children"><a href="#">Page Three</a>
					<ul class="submenu">
						<li><a href="#">Sub One</a></li>
						<li><a href="#">Sub Two</a></li>
						<li><a href="#">Sub Three</a></li>
					</ul>
				</li>
				<li><a href="#">Page Four</a></li>
				<li><a href="#">Page Five</a></li>
			</ul>
			<div class="navbar_menu-end">
				<ul class="contact_list">
					<li class="contact_list_email"><a href="mailto:###">email us</a></li>
					<li class="contact_list_tel"><a href="tel:####">01234 567890</a></li>
				</ul>
			</div>
		</nav>
	</div>
</header>
              
            
!

CSS

              
                // Varibles //
$base-size: 1rem;
$size-scale-500: $base-size * 1.33;
$size-scale-600: $base-size * 1.77;
$size-scale-700: $base-size * 2.36;
$hamburger-colour: #000000;
$logo-width: 150px;
$leading-tight: 1.3;
$leading-flat: 1.1;
$text: #000000;
$primary: yellow;
$tertiary: pink;
$bold: 900;

// Utilities //

body {
	margin: 0;
	padding: 0;
}

header {
	box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1);
	background-color: #ffffff;
}

.wrapper {
	max-width: 100rem;
	padding: 0 $size-scale-500;
	margin-left: auto;
	margin-right: auto;
	position: relative;
}

ul[class],
ol[class] {
	padding: 0;
	margin: 0;
	list-style: none;
}


// Blocks //

.navbar {
	padding-top: $size-scale-500;
	padding-bottom: $size-scale-500;
	display: grid;
	align-items: center;
	grid-template-columns: $logo-width 1fr;
	grid-template-areas:
		"logo hamburger"
		"menu menu"
		"menu_end menu_end";
	position: relative;

	@media screen and (min-width: 1023px) {
		grid-template-columns: $logo-width 1fr auto;
		grid-template-areas: "logo menu menu_end";
	}

	.navbar_brand-logo {
		grid-area: logo;
		width: $logo-width;
		height: 70px;
	}

	.hamburger {
		grid-area: hamburger;
		margin-left: auto;
		appearance: none;
		border: 0 solid transparent;
		background-color: transparent;

		@media screen and (min-width: 1023px) {
			display: none;
		}

		.line {
			display: block;
			margin: 8px;
			width: 50px;
			height: 5px;
			background-color: $hamburger-colour;
			transition: all 0.3s ease-in-out;
		}

		&:hover {
			cursor: pointer;
		}

		&.is-active .line:nth-child(2) {
			opacity: 0;
		}

		&.is-active .line:nth-child(1) {
			transform: translateY(13px) rotate(45deg);
		}

		&.is-active .line:nth-child(3) {
			transform: translateY(-13px) rotate(-45deg);
		}
	}

	.nav {
		grid-area: menu;
		overflow: hidden;
		text-align: center;
		align-self: start;
		padding: $size-scale-500 $size-scale-500 0px $size-scale-500;
		margin-left: -$size-scale-500;
		margin-right: -$size-scale-500;
		max-height: 0;
		background-color: #eeeeee;
		opacity: 0;
		transition: opacity .3s ease-in, max-height .5s;
		position: absolute;
		left: 0;
		right: 0;
		top: 21px;
		z-index: -1;

		&.is-active {
			padding: $size-scale-500 $size-scale-500 0px $size-scale-500;
			max-height: 291px;
			opacity: 1;
		}

		@media screen and (min-width: 1024px) {
			overflow: inherit;
			max-height: 70px;
			align-self: center;
			display: block;
			position: static;
			z-index: 1;
		}

		li {
			position: relative;
			margin-left: 0rem;
			padding: 1rem;
			line-height: $leading-tight;
			margin-left: -$size-scale-500;
			margin-right: -$size-scale-500;
			border-bottom: 1px solid #dddddd;

			@media screen and (min-width: 1024px) {
				margin-left: 1rem;
				display: inline-block;

				li {
					margin-right: 1rem;
				}

				&:hover {
					.submenu {
						opacity: 1;
						visibility: visible;
					}
				}
			}
		}
	}

	.navbar_menu-end {
		grid-area: menu_end;
		display: none;
		margin-top: $size-scale-500;
		height: 0;

		&.is-active {
			display: block;
			grid-column: span 2;
			height: 52px;
			transition: height 1s ease-out;
		}

		@media screen and (min-width: 1024px) {
			display: block;
			margin-top: 0;
			height: 52px;
		}

		.contact_list {
			text-align: center;
			width: 100%;

			@media screen and (min-width: 1024px) {
				text-align: right;
			}

			.contact_list_email {
				line-height: $leading-tight;
				a {
					color: $text;

					&:hover {
						color: $tertiary;
					}
				}
			}
			.contact_list_tel {
				color: $primary;
				font-weight: $bold;
				font-size: $size-scale-600;
				line-height: $leading-flat;
			}
		}
	}
}

.submenu {
	position: absolute;
	top: 35px;
	left: 8px;
	text-align: left;
	opacity: 0;
	visibility: hidden;
	z-index: 1;
	background: #eeeeee;
	border-radius: 4px;
	transition: all 0.3s ease-in-out;

	li {
		a {
			width: auto;
			display: block;
			white-space: nowrap;
		}
		&:first-child {
			a {
				&:after {
					content: "";
					position: absolute;
					left: 10px;
					top: -6px;
					border-left: 6px solid transparent;
					border-right: 6px solid transparent;
					border-bottom: 6px solid #eeeeee;
				}
			}
		}
	}
}

              
            
!

JS

              
                // Hamburger Menu

document.addEventListener("DOMContentLoaded", function (event) {
	function menuClass() {
		// Look to menu Classes
		var mobileBtn = document.querySelector(".hamburger");
		var mobileNav = document.querySelector('.nav');

		//Toggle the various states
		mobileBtn.classList.toggle("is-active");
		mobileNav.classList.toggle('is-active');
		
		// Toggle Aria Expanded
		mobileBtn.addEventListener('click', () => {
		 mobileBtn.setAttribute(
			'aria-expanded',
			mobileBtn.getAttribute('aria-expanded') === 'false' 
				 ? 'true'
			  : 'false'
		 )
		});
		
	}

	// Load the window function
	window.onload = function () {
		// Listen for events
		document.querySelector(".hamburger").addEventListener("click", menuClass);
		document.querySelector('.nav').addEventListener('click', menuClass);
	};
	
});
              
            
!
999px

Console