I have this background pattern. But my code just skips to the end. I want a smooth animation from big to small circles.
.loader {
position: absolute;
z-index: 1;
width: 200px;
height: 200px;
background-color: transparent;
background-image: radial-gradient(#363636 10px, transparent 1px);
background-size: 30px 30px;
animation: loaderout 2s forwards;
}
@keyframes loaderout {
100% {
background-image: radial-gradient(#363636 0.7px, transparent 1px);
}
}
<div class="loader" id="loader"></div>
2
Answers
To achieve a smooth animation from big to small circles, you need to update your keyframes to gradually decrease the size of the circles. Here’s how you can modify your code to achieve the desired animation effect:
In this modified version, the keyframes have two stages:
One at 0% where the circles are bigger, and another at 100% where the circles are smaller. By using the
linear
timing function and removing theforwards
value, the animation will smoothly transition between the two stages and continue indefinitely.You can try specifying the style change in animation in a little more detailed way with perecentage selectors, from 0% to 100%, define what happens at 10%, 20%, 30% and so on
Example: