Skip to content

Instantly share code, notes, and snippets.

@andrey-reznik
Last active September 23, 2019 10:16
Show Gist options
  • Select an option

  • Save andrey-reznik/885c785f1f6323a21de522eda82c2a3e to your computer and use it in GitHub Desktop.

Select an option

Save andrey-reznik/885c785f1f6323a21de522eda82c2a3e to your computer and use it in GitHub Desktop.
Burger menu
$background: #3d566e
$color: #000
$height-icon: 20px
$width-line: 31px
$height-line: 3px
$transition-time: 0.4s
$rotation: 45deg
$translateY: ($height-icon / 2)
$translateX: 0
.hamburger-icon
text-align: right
color: $color
width: $width-line
height: $height-icon
position: relative
display: block
margin: ($height-icon * 2) auto $height-icon auto
.line
display: block
background: $color
width: $width-line
height: $height-line
position: absolute
left: 0
border-radius: ($height-line / 2)
transition: all $transition-time
&.line-1
top: 0
&.line-2
top: 50%
&.line-3
top: 100%
&:hover, &:focus
.line-1
transform: translateY($height-line / 2 * -1)
.line-3
transform: translateY($height-line / 2)
&.active
.line-1
transform: translateY($translateY) translateX($translateX) rotate($rotation)
.line-2
opacity: 0
.line-3
transform: translateY($translateY * -1) translateX($translateX) rotate($rotation * -1)
a.hamburger-icon
text-decoration: none
color: #95a5a6
margin: 0.5em 1.5em
display: none
+to(1020px)
display: inline-flex
margin-left: auto
&:hover, &:focus
color: $color
$('a.hamburger-icon').on('click', function (e) {
e.preventDefault()
$(this).toggleClass('active')
$('.menu').toggle()
})
a.hamburger-icon(href='#')
span.line.line-1
span.line.line-2
span.line.line-3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment