A Pen by Roman Milkovic on CodePen.
Created
February 17, 2019 01:29
-
-
Save doylemark/1d6ba87dcc5e82398fbfa4a91cf80dd4 to your computer and use it in GitHub Desktop.
Animation SVG hamburger icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
span.navToggle | |
svg.hamburger(viewbox='0 0 28 28') | |
g(stroke-width='2', stroke-linecap='round', stroke-miterlimit='10') | |
line.one(x1='4', y1='6', x2='24', y2='6') | |
line.two(x1='4', y1='14', x2='24', y2='14') | |
line.three(x1='4', y1='22', x2='24', y2='22') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('.navToggle').click(function() { | |
$('.navToggle').toggleClass('active'); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
position: relative; | |
color: #000; | |
} | |
.navToggle { | |
fill: #333; | |
stroke: #333; | |
color: #333; | |
} | |
.navToggle { | |
cursor: pointer; | |
left: 2em; | |
position: absolute; | |
top: 2em; | |
display: block; | |
} | |
.navToggle svg { | |
height: 1.75em; | |
width: 1.75em; | |
z-index: 999; | |
} | |
.navToggle svg line { | |
transition: transform 0.5s ease; | |
} | |
.hamburger .one { | |
transform: rotate(0deg); | |
} | |
.hamburger .two { | |
transition: opacity 0.2s ease; | |
} | |
.hamburger .three { | |
transform: rotate(0deg); | |
} | |
.active .hamburger .one { | |
transform: translate(8.8px, 0.5px) rotate(45deg); | |
} | |
.active .hamburger .two { | |
opacity: 0; | |
} | |
.active .hamburger .three { | |
transform: translate(-11px, 9px) rotate(-45deg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment