<nav class="nav">
<div class="group">
<a class="logo-link"><span class="logo">LOGO</span><i class="fa fa-home"></i></a>
<div class="nav-toggle">
<button class="c-hamburger c-hamburger--htx">
<span></span>
</button>
</div>
</div>
<ul class="nav-items">
<li class="first-level-item">
<i class="fa fa-smile-o fa-fw"></i>
<span class="nav-item-text">Smile</span>
<ul class="sub-nav">
<li><i class="fa fa-star-o fa-fw"></i> This Star Is Empty</li>
<li><i class="fa fa-star-half-o fa-fw"></i> This Star Is Half Full</li>
<li><i class="fa fa-star fa-fw"></i> This Star Is Full</li>
</ul>
</li>
<li class="first-level-item">
<i class="fa fa-diamond fa-fw"></i>
<span class="nav-item-text">Diamonds</span>
</li>
<li class="first-level-item">
<i class="fa fa-hand-peace-o fa-fw"></i>
<span class="nav-item-text">Peace</span>
</li>
<li class="first-level-item">
<i class="fa fa-map-o fa-fw"></i>
<span class="nav-item-text">Map</span>
</li>
<li class="first-level-item">
<i class="fa fa-rocket fa-fw"></i>
<span class="nav-item-text">Rocket</span>
</li>
<li class="first-level-item">
<i class="fa fa-send-o fa-fw"></i>
<span class="nav-item-text">Airplane</span>
</li>
</ul>
</nav>
<section class="main">
<div class="nav-open-overlay"></div>
</section>
$turq: #1abc9c;
$offWhite: #7f8c8d;
$white: #ffffff;
$black: #000000;
$navEasingDuration: 500ms;
$easeInExpo: all $navEasingDuration cubic-bezier(0.95, 0.05, 0.795, 0.035);
$easeInBack: all $navEasingDuration cubic-bezier(0.6, -0.28, 0.735, 0.045);
$easeInOutBack: all $navEasingDuration cubic-bezier(0.68, -0.55, 0.265, 1.55);
$navEasing: $easeInExpo;
$subNavEasing: all 200ms cubic-bezier(0.95, 0.05, 0.795, 0.035);
body {
background-color: $turq;
position: relative;
}
.main {
width: 100%;
height: 100vh;
position: relative;
.nav-open-overlay {
width: 100%;
height: 100%;
background-color: rgba($black, 0.25);
opacity: 0;
transition: $navEasing;
position: absolute;
}
}
.main .nav-open-overlay--open {
opacity: 1;
pointer-events: auto;
}
.logo-link {
transform: translateY(-10em);
}
.nav {
z-index: 10;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.5);
padding: 9em 1em 0;
background-color: black;
height: 100em;
width: 20em;
position: absolute;
top: -17em;
transform: rotate(45deg);
transform-origin: left top;
transition: $navEasing;
.logo-link {
float: left;
padding-left: 1em;
i {
display: inline-block;
color: rgba($white, 0.75);
font-size: 1.5em;
margin-left: 0.5em;
}
}
.logo {
background-color: white;
padding: 3em;
display: inline-flex;
align-items: center;
justify-content: center;
width: 10px;
height: 10px;
font-size: 0.75em;
box-sizing: border-box;
border-radius: 50%;
}
.nav-toggle {
cursor: pointer;
float: right;
transform: rotate(-45deg);
transition: $navEasing;
}
.nav-items {
color: white;
list-style-type: none;
margin: 0;
padding: 0;
padding-top: 2em;
display: flex;
flex-wrap: wrap;
li.first-level-item {
opacity: 0;
transform: rotateY(-180deg);
cursor: pointer;
display: inline-block;
padding: 1em;
text-align: center;
width: 33.3%;
box-sizing: border-box;
&:hover > i {
color: $turq;
}
> span {
display: block;
text-align: center;
padding: 0.5em 0;
font-family: 'Open Sans', sans-serif;
}
> i {
font-size: 3em;
transition: all 0.15s ease-out;
}
}
}
}
.sub-nav {
transition: $subNavEasing;
width: 320px;
height: 0;
opacity: 0;
pointer-events: none;
> li {
text-align: left;
display: block;
transform: translateX(-15%);
padding: 1em 0;
&:hover > i {
color: $turq;
}
}
}
.c-hamburger {
display: block;
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
width: 96px;
height: 96px;
font-size: 0;
text-indent: -9999px;
border: none;
cursor: pointer;
&:focus {
outline: none;
}
span {
display: block;
position: absolute;
top: 44px;
left: 18px;
right: 18px;
height: 8px;
&:before {
position: absolute;
display: block;
left: 0;
width: 100%;
height: 8px;
background-color: #fff;
content: "";
top: -20px;
}
&:after {
position: absolute;
display: block;
left: 0;
width: 100%;
height: 8px;
background-color: #fff;
content: "";
bottom: -20px;
}
}
}
.c-hamburger--htx {
background-color: transparent;
}
.c-hamburger--htx span {
transition: background 0s 0.3s;
background-color: $white;
}
.c-hamburger--htx span::before,
.c-hamburger--htx span::after {
transition-duration: 0.3s, 0.3s;
transition-delay: 0.3s, 0s;
}
.c-hamburger--htx span::before {
transition-property: top, transform;
}
.c-hamburger--htx span::after {
transition-property: bottom, transform;
}
.c-hamburger--htx.is-active span {
background: none;
}
.c-hamburger--htx.is-active span::before {
top: 0;
transform: rotate(45deg);
}
.c-hamburger--htx.is-active span::after {
bottom: 0;
transform: rotate(-45deg);
}
.c-hamburger--htx.is-active span::before,
.c-hamburger--htx.is-active span::after {
transition-delay: 0s, 0.3s;
}
.nav--open {
transform: rotate(0deg);
top: -10em;
padding-top: 11em;
.nav-toggle {
transform: rotate(0deg);
}
}
.first-level-item--open {
> .sub-nav {
height: 125px;
pointer-events: initial;
opacity: 1;
}
}
.group:after {
content: "";
display: table;
clear: both;
}
View Compiled
$(function() {
var $navToggle = $('.nav-toggle');
var $nav = $('.nav');
var $firstLevelItems = $('.first-level-item');
var $navOverlay = $('.nav-open-overlay');
var $hamburger = $('.c-hamburger');
var $logoLink = $('.logo-link');
var navOpen = false;
$navToggle.click(function() {
toggleBoth();
});
$firstLevelItems.click(function() {
var open = $(this).hasClass('first-level-item--open');
var $this = $(this);
if(open) {
$this.removeClass('first-level-item--open');
} else {
$this.addClass('first-level-item--open');
}
});
var spinIn = function() {
TweenMax.staggerTo($firstLevelItems, 0.25, {rotationY:0, opacity:1, delay: 0.35}, 0.1);
};
var spinOut = function() {
TweenMax.staggerTo($firstLevelItems, 0.15, {rotationY:-180, opacity:0}, 0.1);
};
var logoIn = function() {
TweenMax.to($logoLink, 0.35, {y:0, delay: 0.6, ease: Back.easeOut});
};
var logoOut = function() {
TweenMax.to($logoLink, 0.35, {y:"-10em", ease: Back.easeIn});
};
$navOverlay.click(function() {
if(navOpen) {
toggleBoth();
}
});
var toggleBoth = function() {
toggleNav();
toggleHamburger();
}
var toggleNav = function() {
if(navOpen) {
$nav.removeClass('nav--open');
$navOverlay.removeClass('nav-open-overlay--open');
$firstLevelItems.removeClass('first-level-item--open');
navOpen = false;
spinOut();
logoOut();
} else {
$nav.addClass('nav--open');
$navOverlay.addClass('nav-open-overlay--open');
navOpen = true;
spinIn();
logoIn();
}
};
var toggleHamburger = function() {
var open = $nav.hasClass('nav--open');
if(!open) {
$hamburger.removeClass('is-active');
} else {
$hamburger.addClass('is-active');
}
};
});