Create SVG progress circle

前端 未结 7 1103
再見小時候
再見小時候 2020-12-30 15:34

Anyone know how to create a circle \"progressbar\" in svg? I need to specify the percentage of the circle, så that a color grows in the shape of a cake.

The growing

7条回答
  •  一整个雨季
    2020-12-30 15:56

    Codepen-Link

    30%

    CSS Required for this svg circle

    .flex-wrapper {
      display: flex;
      flex-flow: row nowrap;
    }
    
    .single-chart {
      width: 33%;
      justify-content: space-around ;
    }
    
    .circular-chart {
      display: block;
      margin: 10px auto;
      max-width: 80%;
      max-height: 250px;
    }
    
    .circle-bg {
      fill: none;
      stroke: #eee;
      stroke-width: 3.8;
    }
    
    .circle {
      fill: none;
      stroke-width: 2.8;
      stroke-linecap: round;
      animation: progress 1s ease-out forwards;
    }
    
    @keyframes progress {
      0% {
        stroke-dasharray: 0 100;
      }
    }
    
    .circular-chart.orange .circle {
      stroke: #ff9f00;
    }
    
    .percentage {
      fill: #666;
      font-family: sans-serif;
      font-size: 0.5em;
      text-anchor: middle;
    }
    
    
    a {
      font-size: 26px;
    }
    

    .flex-wrapper {
      display: flex;
      flex-flow: row nowrap;
    }
    
    .single-chart {
      width: 33%;
      justify-content: space-around ;
    }
    
    .circular-chart {
      display: block;
      margin: 10px auto;
      max-width: 80%;
      max-height: 250px;
    }
    
    .circle-bg {
      fill: none;
      stroke: #eee;
      stroke-width: 3.8;
    }
    
    .circle {
      fill: none;
      stroke-width: 2.8;
      stroke-linecap: round;
      animation: progress 1s ease-out forwards;
    }
    
    @keyframes progress {
      0% {
        stroke-dasharray: 0 100;
      }
    }
    
    .circular-chart.orange .circle {
      stroke: #ff9f00;
    }
    
    .percentage {
      fill: #666;
      font-family: sans-serif;
      font-size: 0.5em;
      text-anchor: middle;
    }
    
    
    a {
      font-size: 26px;
    }
    30%





    Thanks to sergiopedercini

提交回复
热议问题