Progress Bar with HTML and CSS

前端 未结 15 1061
耶瑟儿~
耶瑟儿~ 2020-12-02 05:13

I want to create a progress bar like in the below image:

\"Progress

I have no idea about

15条回答
  •  执笔经年
    2020-12-02 05:52

    Progress Bar without nested divs... for every element where the css linear-gradient works.

    Here the JSFiddle http://jsfiddle.net/oj1L3y6t/2/

    function show_progress(i) {
      var progress1 = i;
      var progress2 = progress1 + 1;
      var progress3 = progress1 + 2;
    
      var magic = "linear-gradient(to right, #FFC2CE " + progress1 + "% ,red " + progress2 + "% , #FFFFFF " + progress3 + "%)";
      document.getElementById("progress-0").style.background = magic;
    
      var magic = "linear-gradient(to right, lightblue " + progress1 + "% , lightgreen " + progress2 + "%)";
      document.getElementById("progress-1").style.background = magic;
    
      var magic = "linear-gradient(to right, lightblue " + progress1 + "% , #FFFFFF 100%)";
      document.getElementById("progress-2").style.background = magic;
    
      var magic = "linear-gradient(#FFC2CE " + progress1 + "% ,red " + progress2 + "% , #FFFFFF " + progress3 + "%)";
      document.getElementById("progress-3").style.background = magic;
    }
    
    function timeout() {
      t = setTimeout(function() {
        show_progress(t)
        timeout();
      }, 50);
      if (t == 78) {
        clearTimeout(t);
      }
      console.log(t);
    }
    
    timeout();
    #progress-0 {
      border: 1px solid black;
      width: 500px;
      background: #999;
      text-align: center;
    }
    
    #progress-1 {
      border: 1px solid black;
      width: 500px;
      background: #999;
      text-align: center;
      margin-top: 10px;
      border-radius: 10px;
    }
    
    #progress-2 {
      border: 1px solid black;
      width: 500px;
      background: #999;
      text-align: center;
      margin-top: 10px;
    }
    
    #progress-3 {
      border: 1px solid black;
      width: 100px;
      height: 100px;
      background: #999;
      line-height: 100px;
      text-align: center;
      margin-top: 10px;
      border-radius: 200px;
    }
    Loading

    Loading

提交回复
热议问题