4
I’m trying to make an animation with CSS that would be a "sun" passing through an image.
The idea was to have something next of that result:
But in my code the "sun" is jumping from one side to the other and is not animated in the right way. How do I animate with CSS this readial-gradient
( or linear-gradiente
) in the right way?
I tried to use the @keyframes
and change properties
Of: radial-gradient(circle at 100% 50%...
To: radial-gradient(circle at 0% 50%...
But it didn’t work out as you can see below
.box {
width: 300px;
height: 150px;
background-image: radial-gradient(circle at 100% 50%, rgba(255, 155, 61, 0.473), transparent 25%), url(https://unsplash.it/300/150?image=986);
background-size: cover;
background-repeat: no-repeat;
animation: bg 3s linear infinite, none;
}
@keyframes bg {
to {
background-image: radial-gradient(circle at 0% 50%, rgba(255, 155, 61, 0.473), transparent 25%), url(https://unsplash.it/300/150?image=986);
}
}
<div class="box"></div>
Ara is interesting, but then I would need almost 99 steps to get the animation flowing.... I know you could refine more etc, I even understood the concept that you applied, but not to look like they were "missing frames" I should have something like 1%, 3%, 5%, 7% up to 100% I believe there must be a more optimized way to treat this... But I appreciate the contribution!
– hugocsl
I did a search here and I didn’t find anything that made it work or why it doesn’t work using from and to the keyframes. I found similar examples that treated the circle and the image as separate elements! Using position: relative / Absolute, changing background-size.
– Jonathan de Toni
So, I believe that bg-size along with bg-position is the way! Should not need to separate no, although if using a pseudo element in the container should make it easier even, although it is not the option I wanted...
– hugocsl