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

              
                <h1>Frosted Menu</h1>
<nav>
	<div class="menu-btn">
		<div class="line line__1"></div>
		<div class="line line__2"></div>
		<div class="line line__3"></div>
	</div>

	<div class="sub-menu-btn">
		<div class="line line__1"></div>
		<div class="line line__2"></div>
	</div>

	<ul class="nav-links">
		<li class="link">
			<a href="#">Home</a>
		</li>
		<li class="link">
			<a href="#">About</a>
			<ol>
				<li><a href="#">designers</a></li>
				<li><a href="#">developers</a></li>
			</ol>
		</li>
		<li class="link">
			<a href="#">Work</a>
			<ol>
				<li><a href="#">web</a></li>
				<li><a href="#">graphic </a></li>
				<li><a href="#">apps </a></li>
			</ol>
		</li>
		<li class="link">
			<a href="#">Contact</a>
			<ol>
				<li><a href="#">Email</a></li>
				<li><a href="#">Social</a></li>
			</ol>
		</li>
		<li class="link">
			<a href="#">follow me</a>
			<ol>
				<li>
					<a target="_blank" href="https://twitter.com/DevLoop01">
						Twitter <i class="fab fa-twitter"></i>
					</a>
				</li>
				<li>
					<a target="_blank" href="https://codepen.io/dev_loop/">
						Codepen <i class="fab fa-codepen"></i>
					</a>
				</li>
			</ol>
		</li>
	</ul>
</nav>
              
            
!

CSS

              
                * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
body {
	position: relative;
	width: 100%;
	height: 100vh;
	font-family: "Montserrat";
	background-image: url("https://source.unsplash.com/1200x900/?bright,wallpaper,rainbow");
	background-size: cover;
	overflow: hidden;
	&::after {
		content: "";
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.35);
	}
	z-index: 1;
}
@mixin flex-center {
	display: flex;
	justify-content: center;
	align-items: center;
}

h1 {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: rgba(255, 255, 255, 0.8);
	font-size: 3rem;
	text-transform: uppercase;
	letter-spacing: 5px;
	text-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
	white-space: nowrap;
	z-index: 3;
}

nav {
	--transition-time: 500ms;
	position: relative;
	width: 400px;
	height: 100%;
	display: flex;
	align-items: center;
	background: rgba(0, 0, 0, 0.45);
	backdrop-filter: blur(20px);
	transform: translateX(-100%);
	transition: all 800ms cubic-bezier(0.8, 0, 0.33, 1);
	z-index: 4;

	a {
		text-transform: uppercase;
		font-size: 1.4rem;
		font-weight: 900;
		letter-spacing: 3px;
		text-decoration: none;
		user-select: none;
		color: #fff;
	}

	.nav-links {
		--link-height: 60px;
		position: relative;
		width: 100%;

		li {
			@include flex-center();
			position: relative;
			width: 100%;
			height: var(--link-height);
			list-style: none;
			opacity: 0;
			transform: translateX(-50%);
			transition: all var(--transition-time) cubic-bezier(0.8, 0, 0.33, 0.9);
			transition-delay: calc(30ms + var(--delay));
			cursor: pointer;
			z-index: 8;
			&:hover {
				color: rgba(255, 255, 255, 0.85);
			}
			a {
				pointer-events: none;
			}

			ol {
				display: none;
			}
		}
		.hover-el {
			position: absolute;
			width: 100%;
			height: var(--link-height);
			top: var(--y);
			left: var(--x);
			opacity: 0;
			background: radial-gradient(
				circle at var(--mousex) var(--mousey),
				rgba(0, 0, 0, 0.15) 0%,
				rgba(0, 0, 0, 0.45) 100%
			);
			transition: all 200ms cubic-bezier(0.215, 0.61, 0.355, 1);
			pointer-events: none;
			z-index: 5;
		}
	}

	.sub-menu {
		--link-height: 60px;
		position: absolute;
		top: 50%;
		left: 0;
		width: 100%;
		transform: translateY(-50%);
		ol {
			list-style: none;
			li {
				@include flex-center();
				height: var(--link-height);
				transition: all var(--transition-time) ease;
				transition-delay: calc(30ms + var(--delay));
				cursor: pointer;
				&:hover {
					background: rgba(0, 0, 0, 0.25);
				}
				&.off-menu {
					opacity: 0;
					transform: translateY(30%);
				}
				&.on-menu {
					opacity: 1;
					transform: translateY(0%);
				}

				a {
					font-size: 1.2rem;
					font-weight: normal;
				}
			}
		}
	}

	// Buttons
	.sub-menu-btn {
		--icon-width: 40px;
		position: absolute;
		top: 6%;
		left: 10%;
		width: var(--icon-width);
		height: var(--icon-width);
		background: rgba(0, 0, 0, 0.25);
		border-radius: 5px;
		opacity: 0;
		transform: translateX(-100%);
		transition: all var(--transition-time) cubic-bezier(0.8, 0, 0.33, 1.25);
		cursor: pointer;
		z-index: 8;
		pointer-events: none;

		.line {
			width: calc(var(--icon-width) - 28px);
			height: 2px;
			background: #fff;
			display: flex;
			flex-direction: column;
			margin: 12px 10px;
			&__1 {
				transform-origin: left;
				transform: rotate(-35deg) translate(-1px, 8px);
			}
			&__2 {
				transform-origin: left;
				transform: rotate(35deg) translate(-1px, -8px);
			}
		}
	}

	.menu-btn {
		@include flex-center();
		--icon-width: 25px;
		position: absolute;
		top: 5%;
		right: -15%;
		width: calc(var(--icon-width) + 25px);
		height: calc(var(--icon-width) + 25px);
		flex-direction: column;
		transition: all calc(100ms + var(--transition-time)) cubic-bezier(0.8, 0, 0.33, 1.25);
		cursor: pointer;
		z-index: 10;
		&.close {
			.line {
				&__1 {
					transform: rotate(45deg) translate(2px, -3px);
				}
				&__2 {
					transform: rotate(-45deg);
				}
				&__3 {
					transform: rotate(45deg) translate(-2px, 3px);
				}
			}
		}
		.line {
			width: var(--icon-width);
			background: #fff;
			height: 2px;
			margin: 3px 0;
			transition: all calc(var(--transition-time) + 100ms) cubic-bezier(0.9, 0, 0.33, 1);
			&__1 {
				width: var(--icon-width);
				transform-origin: left;
			}
			&__2 {
				width: var(--icon-width);
				transform-origin: center;
			}
			&__3 {
				width: var(--icon-width);
				transform-origin: right;
			}
		}
	}

	&.nav-open {
		transform: translateX(0%);
		.menu-btn {
			right: 10%;
		}
		.nav-links {
			li {
				transform: translateX(0);
				opacity: 1;
			}
		}
	}
	&.sub-menu-open {
		.sub-menu-btn {
			opacity: 1;
			transform: translateX(0);
			pointer-events: all;
		}
		.nav-links {
			li {
				pointer-events: none;
				opacity: 0;
				transform: translateY(-10%);
			}
			.hover-el{
				opacity: 0;
			}
		}
	}
}

              
            
!

JS

              
                console.clear();

const nav = document.querySelector("nav");
const navLinksContainer = document.querySelector(".nav-links");
const navLinks = [...document.querySelectorAll(".link")];
const menuBtn = document.querySelector(".menu-btn");
const subMenuBtn = document.querySelector(".sub-menu-btn");

function createHoverEl() {
	let hoverEl = document.createElement("div");
	hoverEl.className = "hover-el";
	hoverEl.style.setProperty("--y", "0px");
	hoverEl.style.setProperty("--mousex", "0px");
	hoverEl.style.setProperty("--mousey", "0px");
	navLinksContainer.appendChild(hoverEl);
}
createHoverEl();

navLinks.forEach((link, index) => {
	let hoverEl = navLinksContainer.querySelector(".hover-el");
	link.style.setProperty("--delay", `${index * 50}ms`);
	link.addEventListener("mousemove", function(e) {
		hoverEl.style.setProperty("--y", `${index * 60}px`);
		hoverEl.style.setProperty("opacity", "1");
		hoverEl.style.setProperty("--mousex", `${e.pageX - hoverEl.offsetLeft}px`);
		hoverEl.style.setProperty("--mousey", `${e.pageY - hoverEl.offsetTop}px`);
	});
	navLinksContainer.addEventListener("mouseout", function() {
		hoverEl.style.setProperty("opacity", "0");
	});
	link.addEventListener("click", function() {
		let hoverEl = navLinksContainer.querySelector(".hover-el");
		hoverEl.style.opacity = '0';
		toggleSubmenu(link);
	});
});

menuBtn.addEventListener("click", function() {
	nav.classList.toggle("nav-open");
	menuBtn.classList.toggle("close");
});
subMenuBtn.addEventListener("click", function() {
	nav.classList.toggle("sub-menu-open");
	removeSubmenu();
});

function toggleSubmenu(el) {
	let subMenu = nav.querySelector(".sub-menu");
	if (el.children[1]) {
		createSubmenu(el);
	} else if (nav.contains(subMenu)) {
		removeSubmenu();
	} else {
		return;
	}
}

function createSubmenu(el) {
	let subMenuContainer = document.createElement("div");
	subMenuContainer.className = "sub-menu";
	let subMenuItem = el.children[1].cloneNode(true);
	let subMenuItemList = [...subMenuItem.children];
	subMenuItemList.forEach((item, index) => {
		item.classList.add("off-menu");
		item.style.setProperty("--delay", `${index * 40}ms`);
	});
	nav.classList.toggle("sub-menu-open");
	nav.appendChild(subMenuContainer);
	subMenuContainer.appendChild(subMenuItem);
	setTimeout(function() {
		subMenuItemList.forEach(item => {
			item.classList.remove("off-menu");
			item.classList.add("on-menu");
		});
	}, 200);
}
function removeSubmenu() {
	let subMenu = nav.querySelector(".sub-menu");
	let subMenuItemList = [...subMenu.children[0].children];
	if (nav.contains(subMenu)) {
		subMenuItemList.forEach(item => {
			item.classList.add("off-menu");
			item.classList.remove("on-menu");
		});
		setTimeout(function() {
			nav.removeChild(subMenu);
		}, 500);
	}
}

              
            
!
999px

Console