<h1><span style="font-size:2.75em;">100% CSS</span><br>Hamburger Animation</h1>
<input id="toggle" type="checkbox"></input>
<label for="toggle" class="hamburger">
<div class="top-bun"></div>
<div class="meat"></div>
<div class="bottom-bun"></div>
</label>
<div class="nav">
<div class="nav-wrapper">
<nav>
<a href="#">HOME</a><br>
<a href="#">ABOUT</a><br>
<a href="#">WORK</a><br>
<a href="#">SERVICES</a>
</nav>
</div>
</div>
body {
background: #336193;
color: #6ecddd;
font-family: 'Bebas';
text-align: center;
max-width: 100%;
overflow-x: hidden;
padding: 0;
margin: 0;
}
h1 {
text-align: center;
letter-spacing: 1px;
word-spacing: 0.15em;
font-size: 3em;
line-height: 1.2;
transform: translateY(52%);
}
#toggle {
display: none;
}
/**
Hamburger
**/
.hamburger {
position: absolute;
top: 5em;
right: 5%;
margin-left: -2em;
margin-top: -45px;
width: 2em;
height: 45px;
z-index: 5;
}
.hamburger div {
position: relative;
width: 3em;
height: 7px;
border-radius: 3px;
background-color: #f8982b;
margin-top: 8px;
transition: all 0.3s ease-in-out;
}
/**
Nav Styles
**/
.nav {
position: fixed;
width: 100%;
height: 100%;
background-color: #090E6B;
top: -100%; left: 0; right: 0; bottom: 0;
overflow: hidden;
transition: all 0.3s ease-in-out;
transform: scale(0);
}
.nav-wrapper {
position: relative;
overflow: hidden;
overflow-y: auto;
height: 100%;
}
nav {
text-align: left;
margin-left: 25%;
}
nav a {
position: relative;
text-decoration: none;
color: #6ecddd;
font-size: 2em;
display: inline-block;
margin-top: 1.25em;
transition: color 0.2s ease-in-out;
letter-spacing: 1px;
}
nav a:before {
content: '';
height: 0;
position: absolute;
width: 0.25em;
background-color: white;
left: -0.5em;
transition: all 0.2s ease-in-out;
}
nav a:hover {
color: white;
}
nav a:hover:before {
height: 100%;
}
/**
Animations
**/
#toggle:checked + .hamburger .top-bun {
transform: rotate(-45deg);
margin-top: 25px;
}
#toggle:checked + .hamburger .bottom-bun {
opacity: 0;
transform: rotate(45deg);
}
#toggle:checked + .hamburger .meat {
transform: rotate(45deg);
margin-top: -7px;
}
#toggle:checked + .hamburger + .nav {
top: 0;
transform: scale(1);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.