Animating linear-gradient to create a loading bar

css progress bar animation
indeterminate progress bar css
html5 progress bar animation
css gradient animation
gradient progress bar css
css progress step bar generator
html progress bar
repeating-linear-gradient generator

I want to build a loading bar, with one coloured element going a long a grey bar.

I am fairly bad at CSS, so I have some trouble with animating gradients. My current approach is based on this answer: Make some gradient move endlessly in a progress bar like in Windows 7

foo {
  background-color: $cGray300;
  height: 10px;
  background: linear-gradient(to right,  $cGray300 0%, $cGray300 30%, #fed0d0 30%, #fed0d0 40%, $cGray300 40%, $cGray300 100%) repeat;
  background-size: 50% 100%;
  animation-name: moving-gradient;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}

@-webkit-keyframes moving-gradient {
  0% { background-position: left bottom; }
  100% { background-position: right bottom; }
}

This is the result:

Though I want one, red bigger element that reappears on the left when it disappears on the right.

You don't need a gradient for this, just a pseudo-element, positioning & a transform.

.bar {
  width: 50%;
  height: 10px;
  background: lightgrey;
  margin: 2em auto;
  position: relative;
  overflow: hidden;
}
.bar::after {
  content: '';
  position: absolute;
  height: 100%;
  width: 30%;
  background: red;
  animation: progress 2s infinite linear;
}
@-webkit-keyframes progress {
  0% {
    left: 0;
    transform: translateX(-100%);
  }
  100% {
    left: 100%;
    transform: translateX(0%);
  }
}
<div class="bar"></div>

Gradient Loading Bar, animation-timing-function: linear;. 16. } 17. ​. 18. @keyframes gradient {. 19. 0% { background-position: 0 0; }. 20. 100% { background-position: -200% 0; }. 21. }. Animation linear-gradient load cpu I have a progress bar, I need to make it an animated background, here’s an example: .progress-bar { positio

This Code is Based on @Paulie_D answer and i make it responsive for any sizes and little more changes

to become like material preloader

.state-changed{
position:relative;
width:400px;
height:20px;
border:1px solid silver;
}

.state-changed::after {
        content: '';
        position: absolute;
        height: 2px; 
        background: red;
        animation: progress 1.5s infinite ease-in-out ;
    }
    
    @keyframes progress {
    0% {
        left: 0;
        width: 0;
    }
    50% {
        width: 100%;
    }
    100% {
        right: 0;
        width: 0;
    }
}
<div class="state-changed"></div>

CSS3 Progress Bars, Just a fun experiment creating progress bars made with just CSS3 (no .orange > span { background-color: #f1a165; background-image: linear-gradient(to bottom, If we're set on it, let's add an additional span and then WebKit animate that. CSS Property Used In This Progress Bar or Loading Bar. Let’s talk about this loading bar animation program: I created this effect with CSS animation property. I used CSS @keyframe property to give animation to this progress bar. Basically, I had created 2 divs. First one for the progress bar, the second one is for a shadow effect.

Here's a working pen

Using just CSS:

HTML:

<div class="loader8"></div>

CSS:

@-webkit-keyframes greenglow {
    from {
        left:-120px;
    }
    to {
        left:100%;
    }
}
@-moz-keyframes greenglow {
    from {
        left:-120px;
    }
    to {
        left:100%;
    }
}
@-o-keyframes greenglow {
    from {
        left:-120px;
    }
    to {
        left:100%;
    }
}
@keyframes greenglow {
    from {
        left:-120px;
    }
    to {
        left:100%;
    }
}

.loader8 {
    width:250px;
    height:16px;
    border:1px solid #bbb;
    border-radius:0px;
    position:relative;
    overflow:hidden;
    background: #E6E6E6;
    margin:5px;
}

.loader8:after {
    content: " ";
    display:block;
    width:120px;
    top:-50%;
    height:250%;
    position:absolute;
    animation: greenglow 3s linear infinite;
    -webkit-animation: greenglow 3s linear infinite;
    z-index:2;
    background: #1CAE30;
}

Animated Progress Bars with CSS3, We'll be creating the linear pattern with gradients and using @keyframes to animate the tile. The Animated Overlay. @-webkit-keyframes progress Here I explain basic progress-bar using CSS, HTML, and javascript and you can see another example of the animated progress-bar (circular water fill loading animation.) Tags In CSS CSS3 HTML javascript

Create Your Own CSS3 Progress Bars, The visual effects on the progress bar each need a separate CSS class. For example, the The same applies to the animate and gloss effects. The code to create the gradient effect progress bar is shown below. .gradient  Here's my new animation. Just a loading bar .. but i like 8) Hope u enjoy ♥

Stylish CSS3 progress bars, In this article you'll learn how to create stylish and animated progress bars A blue progress bar using gradient stripes on a dark background  Herein lies the problem with animating CSS gradients. Let’s go visit our friends over at W3Schools for answers: Always be sure to check if a property is actually animatable.

18 CSS Progress Bars, Collection of hand-picked free HTML and CSS progress bar code Demo image​: Animation Progress Bars Animation Progress Bars - GIF Experiment with a new value for the CSS position property to create a progress bar reading Pure CSS and HTML progress bar, using the repeating-linear-gradient . Collection of hand-picked free HTML and CSS progress bar code examples. Update of December 2018 collection. 2 new items.

Comments
  • Use JS/JQ. When the "red element" (let's give it a class 'red') touches the right end then move it to left 0 (or the left of the wrapper). Then move it back to the end.