How do I add an animation here using CSS?
.card:empty {
height: 40rem;
background-image: linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc);
background-size: 25% 15px,85% 20px,83% 20px,85% 20px,83% 20px,90% 15px,92% 15px,87% 15px,93% 15px,20% 15px,40% 15px,40% 15px,25% 15px;
background-position: 0 0, 0 60px,0 95px,0 130px,0 165px,0 220px,0 250px,0 280px,0 310px,0 350px,40% 350px,0 380px,60% 380px;
background-repeat: no-repeat;
}
<div class="card"></div>
2
Answers
I would convert your background declaration into mask, then add a background animation:
Related for more detail about the background animation: Responsive shine animation using linear-gradient as background
I’ve created
@keyframes
that’s calledskeleton
that changesopacity
property to1
on0%
and100%
. And to0
on50%
. Also, just don’t forget to declareanimation
property.So here’s your final code:
Feel free to adjust the animation to better fit your needs.