How to make a progress bar

后端 未结 19 1489
失恋的感觉
失恋的感觉 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:41

    You can use setInterval to create a progress bar.

    function animate() {
      var elem = document.getElementById("bar");   
      var width = 1;
      var id = setInterval(frame, 10);
      function frame() {
        if (width >= 100) {
          clearInterval(id);
        } else {
          width++; 
          elem.style.width = width + '%'; 
        }
      }
    }
    #progress-bar-wrapper {
      width: 100%;
      background-color: #ffffd;
    }
    
    #bar {
      width: 1%;
      height: 30px;
      background-color: orange;
    }

提交回复
热议问题