Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Created February 24, 2017 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeMyUI/a590ec59b12eb14093b47913c550c74d to your computer and use it in GitHub Desktop.
Save CodeMyUI/a590ec59b12eb14093b47913c550c74d to your computer and use it in GitHub Desktop.
SVG folding line hover effect
.cont
%a(href="#") :HOVER
%svg(height="40" width="120")
- (1..120).each do |i|
%line(x1="#{i}" y1="0" x2="#{i}" y2="40")
$c1: #035e7b
$c2: #fff
$c3: #eff1c5
$t: 0.3s
$d: $t / 121
@import url('https://fonts.googleapis.com/css?family=Signika+Negative:700')
body
margin: 0
background-color: $c3
font-family: 'Signika Negative', sans-serif
.cont, .cont > a, svg
position: absolute
height: 40px
width: 120px
.cont
top: 50vh
left: 50vw
margin: -20px 0 0 -60px
a
z-index: 2
display: block
line-height: 40px
text-align: center
text-decoration: none
font-size: 20px
color: $c3
transition: all $t
&:hover
~ svg > line:nth-child(odd)
transform: scaleY(1.2)
opacity: 0.2
~ svg > line:nth-child(even)
transform: scaleY(-0.2) translateX(-1px)
opacity: 0.2
transform: scale(1.1)
color: $c1
svg
overflow: visible
line
stroke: $c1
stroke-width: 1px
transition: all $t
transform-origin: 50% 0%
@for $i from 1 through 121
line:nth-child(#{$i})
transition-delay: $i * $d
&:hover
line:nth-child(odd)
transform: scaleY(1.2)
line:nth-child(even)
transform: scaleY(-0.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment