Skip to content

Instantly share code, notes, and snippets.

@merli129
Last active February 13, 2017 16:50
Show Gist options
  • Select an option

  • Save merli129/55c3f609fc7a898a38c4f45d644ddbed to your computer and use it in GitHub Desktop.

Select an option

Save merli129/55c3f609fc7a898a38c4f45d644ddbed to your computer and use it in GitHub Desktop.
Animated Sandwich Icon
<div id='sandwich'>
<div class='sw-topper'></div>
<div class='sw-bottom'></div>
<div class='sw-footer'></div>
</div>
$("#sandwich").click(function() {
$("#sandwich").toggleClass("active");
});
$w: 27px
$h: 3px
#sandwich
width: $w
height: $h
position: absolute
top: 0
bottom: 20px
left: 0
right: 0
margin: auto
.sw-topper
position: relative
top: 0
width: $w
height: $h
background: rgb(255, 255, 255)
border: none
border-radius: 4px 4px 4px 4px
transition: transform 0.5s, top 0.2s
//transition-delay: 0.2s, 0s
.sw-bottom
position: relative
width: $w
height: $h
top: $h * 2
background: rgb(255, 255, 255)
border: none
border-radius: 4px 4px 4px 4px
transition: transform 0.5s, top 0.2s
transition-delay: 0.2s, 0s
.sw-footer
position: relative
width: $w
height: $h
top: $h * 4
background: rgb(255, 255, 255)
border: none
border-radius: 4px 4px 4px 4px
transition: all 0.5s
transition-delay: 0.1s
#sandwich.active
.sw-topper
top: $h*3
transform: rotate(140deg)
.sw-bottom
top: $h*2
transform: rotate(-140deg)
.sw-footer
opacity: 0
top: 0
transform: rotate(180deg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment