Skip to content

Instantly share code, notes, and snippets.

@alkrauss48
Last active August 29, 2015 14:05
Show Gist options
  • Save alkrauss48/0865bf9f536643a1d09f to your computer and use it in GitHub Desktop.
Save alkrauss48/0865bf9f536643a1d09f to your computer and use it in GitHub Desktop.
Responsive Nav - 3 Lines Turn Into an X when Clicked
<!-- An example of this exact code can be found live at http://thesocietea.org/ - just shrink the screen down -->
<nav class="nav">
<ul>
<li>
<a id="responsive-menu-icon">
<span class="line-one"></span>
<span class="line-two"></span>
<span class="line-three"></span>
</a>
</li>
</ul>
</nav>
$(document).ready(function(){
$('#responsive-menu-icon').click(function(){
$(this).toggleClass('active-mobile');
});
});
// Written assuming Compass is installed
span.line-one { top: 7px; }
span.line-two { top: 14px; }
span.line-three { top: 21px; }
#responsive-menu-icon {
display: block;
position: relative;
width: 25px;
height: 25px;
span {
@include transition(all 0.35s ease-in-out);
height: 3px;
width: 25px;
background-color: white;
display: block;
position: absolute;
right: 0;
}
&.active-mobile {
span.line-one, span.line-two {
top: 14px;
@include rotate(45deg);
}
span.line-three {
top: 14px;
@include rotate(-45deg);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment