Howto

How To Create Simple Animation Using Css, Html And Javascript

How To Create Simple Animation Using Css, Html And Javascript

Simple Animation source:google

Step 1) Add HTML

<div id=”myProgress”>

<div id=”myBar”></div>

</div>

Step 2) Add CSS:

#myProgress {

position: relative;

width: 100%;

height: 30px;

background-color: grey;

}

#myBar {

position: absolute;

width: 1%;

height: 100%;

background-color: green;

}

Step 3) Add JavaScript:

Create the Animation Using JavaScript:

function move() {

var elem = document.getElementById(“myBar”);

var width = 1;

var id = setInterval(frame, 10);

function frame() {

if (width >= 100) {

clearInterval(id);

} else {

width++;

elem.style.width = width + ‘%’;

}

}

}

 

 

 

credit: http://www.w3schools.com/

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


P.S. Thanks for reading this far! If you found value in this, we’d really appreciate it if you recommend this post (by clicking the share buttons) so other people can learn!

Found this Howto helpful? Subscribe for more!

You may also learn:

Comments
To Top