A Pen by Sebastian Rothbucher on CodePen.
Created
January 12, 2020 16:59
-
-
Save sebastianrothbucher/d79c8bb71fd80305ab93ff3c373e7d62 to your computer and use it in GitHub Desktop.
interactive effect
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
<button onclick="clck()">click me!</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
var clckTo=null; | |
function clck() { | |
var tgt=event.target; | |
clearTimeout(clckTo); // (if any) | |
tgt.classList.remove('clicked'); | |
clckTo=setTimeout(function() { // sure it's gone | |
tgt.classList.add('clicked'); | |
clckTo=setTimeout(function() { | |
tgt.classList.remove('clicked'); | |
}, 900); | |
}); | |
} |
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
$bg: #124559; // thx, coolors.co | |
button { | |
border: none; | |
border-radius: 0; | |
font-size: 16px; | |
padding: 11px 30px 12px 29px; | |
background-color: $bg; | |
color: white; | |
box-shadow: 2px 2px 4px -1px grey; | |
position: relative; | |
overflow: hidden; | |
&:after { | |
content: ' '; | |
position: absolute; | |
display: block; | |
left: 50%; | |
top: 50%; | |
width: 0; | |
height: 0; | |
border-radius: 500px; | |
background-color: white; | |
opacity: 0.5; | |
} | |
&.clicked { | |
&:after { | |
left: calc(50% - 200px); | |
top: calc(50% - 200px); | |
width: 400px; | |
height: 400px; | |
opacity: 0; | |
transition: left, top, width, height, opactity 0.7s, 0.7s, 0.7s, 0.7s, 0.7s; // only 'out' | |
} | |
} | |
&:hover, &:focus { | |
background-color: lighten($bg, 5%); | |
padding: 12px 29px 11px 30px; | |
box-shadow: none; | |
} | |
&:focus { | |
outline: none; | |
} | |
&:active { | |
background-color: lighten($bg, 15%); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment