I am trying to apply the following animation to an svg circle element:
$color: #65ff78;
html, body {
width: 100%;
height: 100%;
}
body {
background-color: #4e4e4e;
display: flex;
align-items: center;
justify-content: center;
}
.circle-ripple {
background-color: #35ffc3;
width: 1em;
height: 1em;
border-radius: 50%;
animation: ripple 0.7s linear infinite;
}
@keyframes ripple {
0% {
box-shadow: 0 0 0 0 rgba($color, 0.3),
0 0 0 1em rgba($color, 0.3),
0 0 0 3em rgba($color, 0.3),
0 0 0 5em rgba($color, 0.3);
}
100% {
box-shadow: 0 0 0 1em rgba($color, 0.3),
0 0 0 3em rgba($color, 0.3),
0 0 0 5em rgba($color, 0.3),
0 0 0 8em rgba($color, 0);
}
}
https://codepen.io/FabienMotte/pen/gPKVxE
Changing the div to a circle did not work, as expected.
In the above codepen a div element has been used, but can I apply the same effect to an svg circle element?
Thanks in advance.
You'll have to use a stack of circles instead of shadows. The radius of a
<circle>
is not CSS-animatable, so as a workaround you'll have to use a scale transformation. (A SMIL animation could work on the radius, but would not be compatible with Microsoft browsers.)