Created
July 20, 2019 20:47
-
-
Save beseidel/23134df0005c793cbdd24d1c024256a1 to your computer and use it in GitHub Desktop.
Border animation - button
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
<!-- It's very, very hacky so I don't advise you to use it on a live site ;) --> | |
<div class="container"> | |
<div class="button-wrapper"> | |
<div class="button"> | |
<span class="text">Not really clickable</span> | |
</div> | |
</div> | |
<div class="button-wrapper"> | |
<div class="button"> | |
<span class="text">Hover me</span> | |
</div> | |
</div> | |
<div class="button-wrapper"> | |
<div class="button"> | |
<span class="text">And Me</span> | |
</div> | |
</div> | |
</div> |
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 { | |
background-color: #555555; | |
} | |
$colors: #FF8B94, #02A7E1, #98CB4A, #AE5A41, #F7D842; | |
@for $i from 1 through length($colors) { | |
.container .button-wrapper:nth-child(#{length($colors)}n+#{$i}) div:before { | |
border-color: nth($colors, $i); | |
} | |
.container .button-wrapper:nth-child(#{length($colors)}n+#{$i}) div { | |
border-color: nth($colors, $i); | |
} | |
} | |
.container { | |
z-index: 99; | |
height: 100vh; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
flex: 0; | |
flex-wrap: wrap; | |
.button-wrapper { | |
overflow:hidden; | |
.button { | |
position:relative; | |
text-transform: uppercase; | |
color: #fff; | |
border: solid 2px #02A7E1; | |
padding: 10px 30px; | |
z-index:1; | |
&::before { | |
position:absolute; | |
border-bottom: solid 3px; | |
content:''; | |
min-height: 10px; | |
min-width: 100px; | |
z-index:200; | |
left: 50%; | |
transform: translateX(-50%); | |
top: 60%; | |
opacity:1; | |
transition-duration:0.5s; | |
} | |
&::after { | |
pointer-events: none; | |
position:absolute; | |
content:''; | |
width: 600px; | |
height: 160px; | |
border-radius:50%; | |
background-color: #555555; | |
//background-color: red; | |
//border: solid 2px red; | |
top:-120%; | |
left:-30%; | |
z-index: -10; | |
//transform: rotate(30deg); | |
transition-duration: 2s; | |
} | |
&:hover:after { | |
width:0; | |
height:50px; | |
} | |
&:hover:before { | |
opacity:0; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment