I have a button that, when I select it, I want to add an animated class with a circle that increases in size until the entire background takes on the secondary color. The only problem is that the animation isn't working well, it's crashing. Does anyone know how I can go about solving this problem? Below I leave more or less the method I am using
function change(el){
el.classList.add('animated')
}
.animated{
animation: disable 1s linear 1 alternate;
}
@keyframes disable{
from{
background: radial-gradient(circle, #00c7be 99%, #4e5d78 100%);
}
to{
background: radial-gradient(circle, #00c7be 0%, #4e5d78 1%);
}
}
<button onclick="change(this)">
button
</button>
If I understand what you want to do correctly, I would start by creating an SVG containing a circle with a radial gradient fill.
(Note that I’m converting the SVG to PNG for purposes of this answer, because Stack Overflow doesn’t allow SVG uploads.)
Then I would use this graphic as the button background, and animate its size from 0% to something large like 800%.