How to make a progress bar

后端 未结 19 1534
失恋的感觉
失恋的感觉 2020-12-04 18:09

How would one go about making a progress bar in html/css/javascript. I don\'t really want to use Flash. Something along the lines of what can be found here: http://dustincur

19条回答
  •  盖世英雄少女心
    2020-12-04 18:32

    You can create a progress-bar of any html element that you can set a gradient to. (Pretty cool!) In the sample below, the background of an HTML element is updated with a linear gradient with JavaScript:

    myElement.style.background = "linear-gradient(to right, #57c2c1 " + percentage + "%, #4a4a52 " + percentage + "%)";
    

    PS I have set both locations percentage the same to create a hard line. Play with the design, you can even add a border to get that classic progress-bar look :)

    https://jsfiddle.net/uoL8j147/1/

提交回复
热议问题