I am using CSS animation to show an indeterminate progress bar. Refer code below. If you'll notice there are 2 moving gradient at any point of time, i.e. when the 1st one reaches 50% of the width, 2nd one starts. I know that I have defined the css that way using webkit-background-size(50% and 100%). However what I am not able to do is make sure that there should be only 1 moving part at any point of time - i.e. once the animation reaches the right end of the div only then it should start it from the left end. Any pointers on this?
Refer https://jsfiddle.net/AnuragSinha/nuokygpe/1/ and corresponding code below.
@-webkit-keyframes moving-gradient {
0% { background-position: left bottom; }
100% { background-position: right bottom; }
}
.loading-gradient {
width: 200px;
height: 30px;
background: -webkit-linear-gradient(
left,
#e9e9e9 50%,
#eeefef 100%
) repeat;
-webkit-background-size: 50% 100%;
-webkit-animation-name: moving-gradient;
-webkit-animation-duration: 1s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
<div class="loading-gradient" style="width: 200px; height: 30px"> </div>