Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

need help creating a loading bar

I am trying to make a loading bar, just like in monkey type when it’s ‘downloading your data and applying settings’. I just want to make the bar, and the orange gradient move from the leftmost to the right.

I tried using a linear gradient for this, but it seems that it just flips between the two states ( which is also random).

body {
    background: black;
}

.line {
    position: absolute;
    width: 200px;
    height: 25px;
    margin: auto;
    background: linear-gradient(to right, orange, grey);
    border-radius: 25px;
    animation: gradual 2s ease-in-out infinite;
}

@keyframes gradual {
    0% {
        background: linear-gradient(to right, 0% orange, 100% grey);
    }

    100% {
        background: linear-gradient(to right, 100% orange, 0% grey);
    }
}
<div class='line'></div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This code snippet utilizes CSS animations and keyframes to create a loading bar effect with an orange gradient moving from left to right. By animating the background-position. The animation duration is set to 2 seconds.

body {
  background: black;
}

.line {
  position: absolute;
  width: 200px;
  height: 25px;
  margin: auto;
  background: linear-gradient(to right, orange, grey);
  border-radius: 25px;
  animation: moveGradient 2s linear infinite;
}

@keyframes moveGradient {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}
<div class='line'></div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading