I have unsuccessfully been trying to animate a linear gradient border on a div
. I took inspiration from
this image. I want the border to be transparent between the two gradients, like in the picture. But I also want the gradient to look like it is moving in a circle around the circle div
.
I tried making the circle rotate in an animation, which works but I cannot add a gradient to a border-color
property so instead I used an ::after
property to add a circle behind the main div
so that it looks like a circle. All of this works with a on the background but the main problem from here is that I cannot get the gaps between 2 different gradient borders on opposite sides of the circle.
scss:
#home-page {
i {
position: absolute;
color: $medium-red;
top: 50%;
left: 50%;
font-size: 400px;
// border-width: 2px;
// border-style: solid;
animation: spin 4s linear infinite;
// border-color: transparent $beige;
border-radius: 50%;
&::after {
content: "";
background: linear-gradient(60deg, $beige, $light-red);
position: absolute;
top: -3px;
left: -3px;
right: -3px;
bottom: -3px;
border-radius: 50%;
z-index: -1;
}
}
}
@keyframes spin {
0% {
transform: translate(-50%, -50%);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
html:
<div id="homepage">
<i>(font awesome icon of a circle)</i>
</div>
2
Answers
HTML
CSS:
test how it works HERE
You could use SVG for the gradient arcs like: