:active (JS)
by Sasabee
HTML
<div id="btn"></div>
CSS
body {
display: flex;
justify-content: center;
align-items: center;
background-color: #000;
height: 100vh;
}
div {
cursor: pointer;
background-color: #f00;
width: 300px;
height: 100px;
font-size: 24px;
font-weight: bold;
color: #000;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
position: relative;
}
div::before {
content: "BUTTON";
}
@keyframes hado {
to {
width: 700px;
height: 700px;
opacity: 0;
}
}
.anim::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0;
height: 0;
opacity: 1;
background-color: rgba(255, 255, 255, 0.5);
border-radius: 50%;
animation: 1s hado;
}
JavaScript
const el = document.getElementById('btn');
el.addEventListener('click', (e)=>e.target.classList.add('anim'));
el.addEventListener('animationend', (e)=>e.target.classList.remove('anim'));