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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <nav>
	<ul class="main-nav">
		<li id="A" class="item main-item has-sub-items"><span>Item A</span>
			<ul class="sub-nav level1">
				<li class="item sub-item level1"><span>sub-item A.1</span></li>
				<li class="item sub-item level1"><span>sub-item A.2</span></li>
				<li class="item sub-item level1"><span>sub-item A.3</span></li>
			</ul>
		</li>
		<li id="B" class="item main-item has-sub-items"><span>Item B</span>
			<ul class="sub-nav level1">
				<li class="item sub-item level1"><span>sub-item B.1</span></li>
				<li class="item sub-item level1"><span>sub-item B.2</span></li>
				<li class="item sub-item level1 has-sub-items"><span>sub-item B.3</span>
					<ul class="sub-nav level2">
						<li class="item sub-item level2"><span>sub-item B.3.1</span></li>
						<li class="item sub-item level2"><span>sub-item B.3.2</span></li>
						<li class="item sub-item level2"><span>sub-item B.3.3</span></li>
					</ul>
				</li>
				<li class="item sub-item level1"><span>sub-item 3</span></li>
			</ul>
		</li>
		<li id="C" class="item main-item has-sub-items"><span>Item C</span>
			<ul class="sub-nav level1">
				<li class="item sub-item level1 has-sub-items"><span>sub-item C.1</span>
					<ul class="sub-nav level2">
						<li class="item sub-item level2"><span>sub-item C.1.1</span></li>
						<li class="item sub-item level2"><span>sub-item C.1.2</span></li>
						<li class="item sub-item level2"><span>sub-item C.1.3</span></li>
					</ul>
				</li>
				<li class="item sub-item level1 has-sub-items"><span>sub-item C.2</span>
					<ul class="sub-nav level2">
						<li class="item sub-item level2"><span>sub-item C.2.1</span></li>
						<li class="item sub-item level2"><span>sub-item C.2.2</span></li>
					</ul>
				</li>
			</ul>
		</li>
		<li id="D" class="item main-item has-sub-items"><span>Item D</span>
			<ul class="sub-nav level1">
				<li class="item sub-item level1"><span>sub-item D.1</span></li>
				<li class="item sub-item level1"><span>sub-item D.2</span></li>
				<li class="item sub-item level1"><span>sub-item D.3</span></li>
				<li class="item sub-item level1"><span>sub-item D.4</span></li>
				<li class="item sub-item level1"><span>sub-item D.5</span></li>
			</ul>
		</li>
	</ul>
	<ul class="sup-nav">
		<li><a href="">About</a></li>
		<li><a href="">Careers</a></li>
		<li><a href="">Magrath Global</a></li>
		<li><a href="">Contact</a></li>
	</ul>
</nav>
              
            
!

CSS

              
                nav {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100px;
	background-color: #031C2D;
}

.main-nav {
	display: flex;
	width: 100%;
	justify-content: center;
	list-style-type: none;
	margin: 0;
	padding: 0;
	position: absolute;
	bottom: 10px;
	left: 50%;
	color: white;
	transform: translateX(-50%);
}

.main-item {
	margin-right: 20px;
}

.main-item:last-child {
	margin-left: 0;
}

/* Sub Nav */

.sub-nav {
	position: fixed;
	left: 0;
	top: 28px;
	width: 100%;
	height: calc(100vh - 100px);
	color: white;
	background-color: #031C2D;
	margin: 0;
	padding: 50px 0 0 50px;
	list-style-type: none;
}

/* Sub Nav Items*/

.sub-item.level1 {
	font-size: 25px;
	line-height: 2em;
	font-family: Optima;
	font-weight: bold;
	position: relative; 
}

/* Sub Sub Nav */

.sub-nav.level2 {
	margin: 0;
	padding: 0;
	list-style-type: none;
	position: absolute;
	left: 50%;
	top: 28px;
}

/* Sup Nav */

.sup-nav {
	display: flex;
	list-style-type: none;
	margin: 0;
	padding: 0;
	position: absolute;
	right: 20px;
	top: 10px;
	font-size: 12px;
}

.sup-nav li {
	margin-left: 10px;
}

a {
	color: white;
	text-decoration: none;
}
              
            
!

JS

              
                console.clear();

setupMenu($('.main-nav'));

function setupMenu(nav) {
	// Go through all of this level's items
	nav.children().each((i, el) => {
		var el = $(el),
				subnav = el.children('ul');
		
		// Check if the current item has sub-items
		if ( subnav.length > 0 ) {
			// If it does, create the animation and events for it
			var	tl = new TimelineMax({paused: true});

			tl.fromTo(subnav, .8, {height: 0}, {height: '100vh', ease: Power4.easeInOut})
				.staggerFromTo(subnav.children('li'), .5, {y: 20, autoAlpha: 0}, {y: 0, autoAlpha: 1, ease: Power4.easeInOut}, .05, '-=.5');

			el.on('mouseover', () => { tl.play(); });
			el.on('mouseleave', () => { tl.reverse(); });
			
			// Set up one level deeper
			setupMenu(subnav);
		}
	});
}

// setupMenu function using classes, unused in this pen
function setupMenu(nav) {
	// Find children that have sub-items
	var els = nav.children('.has-sub-items');
	
	// For each of those, create the timeline
	els.each((i, el) => {
		var el = $(el),
				subnav = el.children('.sub-nav'),
				tl = new TimelineMax({paused: true});

		tl.fromTo(subnav, .8, {height: 0}, {height: '100vh', ease: Power4.easeInOut})
			.staggerFromTo(subnav.children('.sub-item'), .5, {y: 20, autoAlpha: 0}, {y: 0, autoAlpha: 1, ease: Power4.easeInOut}, .05, '-=.5');

		el.on('mouseover', () => { tl.play(); });
		el.on('mouseleave', () => { tl.reverse(); });
		
		// Set up one level deeper
		setupMenu(subnav);
	});
}
              
            
!
999px

Console