Last active
March 8, 2022 00:25
-
-
Save maurocen/8b2bc48f866aa90aa5739e75d1d800b0 to your computer and use it in GitHub Desktop.
Neuromorphic button
This file contains 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
<style> | |
html, body { | |
margin: 0; | |
padding: 0; | |
} | |
.container { | |
align-items: center; | |
background-color: #EEEEEE; | |
display: flex; | |
flex-direction: row; | |
height: 100vh; | |
justify-content: center; | |
width: 100vw; | |
} | |
.neuromorphic { | |
appearance: none; | |
background-color: #EEEEEE; | |
border-radius: 10px; | |
border: 0; | |
box-shadow: 4px 4px 15px 1px #CCCCCC, -4px -4px 15px 1px #FFFFFF; | |
color: #333; | |
font-size: 20px; | |
height: 125px; | |
transition: box-shadow .15s ease; | |
width: 125px; | |
} | |
.neuromorphic--animate { | |
box-shadow: 0 0 0 0 #CCCCCC, 0 0 0 0 #FFFFFF; | |
} | |
</style> | |
<body> | |
<div class="container"> | |
<button class="neuromorphic" id="neuromorphic-button"> | |
CLICK ME | |
</button> | |
</div> | |
<script> | |
document.getElementById('neuromorphic-button').addEventListener('click', function animate() { | |
this.classList.add('neuromorphic--animate'); | |
setTimeout(() => { | |
this.classList.remove('neuromorphic--animate'); | |
}, 150); | |
}) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment