Nav Button Animations
<button class="nav__toggle ex__01">
<span></span>
<span></span>
<span></span>
<span></span>
</button>
<button class="nav__toggle ex__02">
<span></span>
<span></span>
<span></span>
<span></span>
</button>
<button class="nav__toggle ex__03">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</button>
.nav__toggle {
outline: none;
border: 3px solid black;
background: white;
height: 100px;
width: 100px;
display: inline-block;
margin-top: 30px;
margin-left: 100px;
position: relative;
padding: 10px;
span {
height: 6px;
width: 70px;
display: inline-block;
background: black;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
transition: transform 0.3s ease, opacity 0.3s ease;
&:nth-child(1) {
top: 30px;
}
&:nth-child(2),
&:nth-child(3) {
top: 45px;
}
&:nth-child(4) {
top: 60px;
}
}
}
// EXAMPLE 01
.ex__01 {
span {
transition: transform 0.3s ease, opacity 0.2s ease;
}
&.open {
span {
&:nth-child(1),
&:nth-child(4){
opacity: 0;
}
&:nth-child(2) {
transform: rotate(-45deg);
}
&:nth-child(3) {
transform: rotate(45deg);
}
}
}
}
// EXAMPLE 02
.ex__02 {
span {
width: 70px;
transition: transform 0.3s ease, width 0.5s ease;
&:nth-child(4){
left: 11px;
right: auto;
transition-delay: 0s;
}
&:nth-child(1){
right: 11px;
left: auto;
transition-delay: 0s;
}
&:nth-child(2),
&:nth-child(3){
transition-delay: 0.3s;
}
}
&.open {
span {
&:nth-child(1),
&:nth-child(4){
width: 0px;
transition-delay: 0.2s;
}
&:nth-child(2) {
transform: rotate(-45deg);
transition-delay: 0s;
}
&:nth-child(3) {
transform: rotate(45deg);
//transition-delay: 0s;
}
}
}
}
// EXAMPLE 03
.ex__03 {
overflow: hidden;
span {
&:nth-child(3){
top: 60px;
}
&:nth-child(5),
&:nth-child(6){
top: 150px;
}
&:nth-child(5) {
transform: rotate(-45deg);
}
&:nth-child(6) {
transform: rotate(45deg);
}
}
&.open {
span {
&:nth-child(1),
&:nth-child(2),
&:nth-child(3),
&:nth-child(4){
transform: translateY(-105px);
}
&:nth-child(5) {
transform: translateY(-105px) rotate(-45deg);
}
&:nth-child(6) {
transform: translateY(-105px) rotate(45deg);
}
}
}
}
$(document).ready(function(){
$('.nav__toggle').on('click', function(){
$(this).toggleClass('open');
});
});
View Pen:
http://codepen.io/DinosVsRobots/pen/ZLbRBL
More animations to be added