JSFiddle - React, Tailwind, and code Playground
by cgough
HTML
<button>test</button>
CSS
button {
position: relative;
overflow: hidden;
padding: 16px 32px;
}
button:after:hover {
content: '';
display: block;
position: absolute;
left: 50%;
top: 50%;
width: 120px;
height: 120px;
margin-left: -60px;
margin-top: -60px;
background: #9a9a9a;
border-radius: 100%;
opacity: .6;
transform: scale(0);
}
@keyframes ripple {
0% {
transform: scale(0);
}
20% {
transform: scale(1);
}
100% {
opacity: 0;
transform: scale(1);
}
}
button:not(:active):after {
animation: ripple 1s ease-out;
}
/* fixes initial animation run, without user input, on page load.
*/
button:after {
visibility: hidden;
}
button:hover:after {
visibility: visible;
}