<button>
<span class="btn-inner">
<span class="btn-text">Click Me<span>
</span
</button>
<button>
<span class="btn-inner">
<span class="btn-text">Click Me<span>
</span
</button>
<button>
<span class="btn-inner">
<span class="btn-text">Click Me<span>
</span
</button>
body {
background-color: #D2D5D8;
}
button {
transition: all 0.2s ease;
background: #d2d5d8;
border:0;
font-weight: bold;
margin: 2rem auto;
display: block;
border-radius: 25px;
position: relative;
outline: none;
padding: 3px;
cursor: pointer;
min-width: 200px;
animation-name: button;
animation-duration: 0.75s;
animation-delay: 1s;
animation-fill-mode: forwards;
}
.btn-text {
color: #333;
font-size: 1rem;
line-height: 1.2rem;
opacity: 1;
animation-name: button-text;
animation-duration: 0.75s;
animation-delay: 1.3s;
animation-fill-mode: backwards;
}
button:before,
button:after,
button span:before,
button span:after{
content: '';
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border-radius: 25px;
}
button:before {
/* box-shadow: -10px -8px 20px #fff; */
animation-name: button-before;
animation-duration: 0.75s;
animation-delay: 1s;
animation-fill-mode: forwards;
}
button:after {
/* box-shadow: 10px 8px 20px #9496B0; */
animation-name: button-after;
animation-duration: 0.75s;
animation-delay: 1s;
animation-fill-mode: forwards;
}
.btn-inner {
max-width: 250px;
position: relative;
background: #d2d5d8;
/* background: linear-gradient(165deg, rgba(255,255,255,1) 0%, rgba(210,213,216,1) 50%, rgba(210,213,216,1) 95%, rgba(148,150,176,1) 100%); */
padding: 1rem 4rem;
display: block;
border-radius: 25px;
position: relative;
animation-name: button-inner;
animation-duration: 0.75s;
animation-delay: 1s;
animation-fill-mode: forwards;
}
button.active .btn-text {
font-size: 0.95rem;
}
button.active .btn-inner:before {
box-shadow: 4px 4px 10px inset #9496B0;
-webkit-box-shadow: 4px 4px 10px inset #9496B0;
}
button.active .btn-inner:after {
box-shadow: -4px -4px 10px inset #fff;
-webkit-box-shadow: -4px -4px 10px inset #fff;
}
@keyframes button-before {
from {box-shadow: 0 0 0 #fff;}
to {box-shadow: -10px -8px 20px #fff;}
}
@keyframes button-after {
from {box-shadow: 0 0 0 #9496B0;}
to {box-shadow: 10px 8px 20px #9496B0;}
}
@keyframes button-inner {
from {background: #d2d5d8;}
to {background: linear-gradient(165deg, rgba(255,255,255,1) 0%, rgba(210,213,216,1) 50%, rgba(210,213,216,1) 95%, rgba(148,150,176,1) 100%);}
}
@keyframes button {
from {background: #d2d5d8;}
to {background: linear-gradient(165deg, rgba(255,255,255,1) 10%, rgba(148,150,176,1) 100%);}
}
@keyframes button-text {
from {opacity: 0;}
to {opacity: 1;}
}
const buttons = document.querySelectorAll('button');
for(let i = 0; i < buttons.length; i++) {
const btn = buttons[i]
btn.addEventListener('click', function(event) {
event.target.classList.toggle('active');
});
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.