Skip to content

Instantly share code, notes, and snippets.

@AntonLitvin
Last active March 22, 2018 11:00
Show Gist options
  • Save AntonLitvin/eaef20b4fbaa84da311e7e4160b441f7 to your computer and use it in GitHub Desktop.
Save AntonLitvin/eaef20b4fbaa84da311e7e4160b441f7 to your computer and use it in GitHub Desktop.
<a href="javascript:void(0);" class="toggle-btn hidden-lg"><span></span></a>
.toggle-btn {
display: block;
width: 28px;
height: 28px;
margin-top: 14px;
}
.toggle-btn span::after, .toggle-btn span::before {
content: "";
position: absolute;
left: 0;
top: 9px;
}
.toggle-btn span::after {
top: 18px;
}
.toggle-btn span {
position: relative;
display: block;
}
.toggle-btn span, .toggle-btn span::after, .toggle-btn span::before {
width: 100%;
height: 2px;
background-color: #fff;
transition: all 0.3s;
backface-visibility: hidden;
border-radius: 2px;
}
.toggle-btn.on span {
background-color: transparent;
}
.toggle-btn.on span::before {
transform: rotate(45deg) translate(-1px, 0px);
}
.toggle-btn.on span::after {
transform: rotate(-45deg) translate(6px, -7px);
}
// Scripts
$('.toggle-btn').on('click', function() {
$(this).toggleClass('on');
$('.main-menu').slideToggle();
return false;
});
$(window).resize(function(){
if($(window).width() > '768') {
$('.main-menu').removeAttr('style');
$('.toggle-btn').removeClass('on');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment