My latest CSS animation project involves creating a stunning 'shine' effect on elements with a specific class. The shine effect itself is flawless, but having all elements shine simultaneously is making it look somewhat artificial.
I've been racking my brain trying to figure out how to vary the shine times for each element, but I can't seem to crack it. Everything I've attempted so far has either been ineffective or simply doesn't work at all.
.loading-element{
position: relative;
background: #e0e0e0;
}
.loading-element::after{ /* this is the animated pseudo-element */
content: "";
position: absolute;
top: 0;
width: 100%;
height: 100%;
background: linear-gradient(to right, rgba(255,255,255,0) 0%,
rgba(255,255,255,0.8) 50%,
rgba(247,247,247,0) 99%,
rgba(247,247,247,0) 100%);
transform: translateX(100%);
animation: shine 1s infinite 3s;
}
.index-load_track-item{
width: 426px;
height: 117px;
margin: 30px 0;
}
.index-load-track_outer-artwork, .index-load-track_outer-waveform{
float: left;
}
.index-load-track_outer-artwork{
width: 117px;
height: 117px;
margin-right: 9px;
}
.index-load-track_outer-artwork .loading-element{
width: 100%;
height: 100%;
}
.index-load-track_outer-waveform{
width: 300px;
height: 60px;
}
.index-load-track_outer-waveform .loading-element{
width: 100%;
height: 100%;
}
/* animation */
@keyframes shine{
0%{ transform:translateX(-100%); }
100%{ transform:translateX(100%); }
}
<div class="index-load_track-item">
<div class="index-load-track_outer-artwork">
<div class="loading-element"></div>
</div>
<div class="index-load-track_outer-waveform">
<div class="loading-element"></div>
</div>
</div>
<div class="index-load_track-item">
<div class="index-load-track_outer-artwork">
<div class="loading-element"></div>
</div>
<div class="index-load-track_outer-waveform">
<div class="loading-element"></div>
</div>
</div>