Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

circular progress bar js

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Radial Progress Bar</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta https-equiv="X-UA-Compatible" content="ie=edge" />
    <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="wrapper-center">
      <div class="progress-bar">
        <svg class="progress" data-progress="10" x="0px" y="0px" viewBox="0 0 80 80">
          <path class="track" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
          <path class="fill" d="M5,40a35,35 0 1,0 70,0a35,35 0 1,0 -70,0" />
          <text class="value" x="50%" y="55%">0%</text>
          <text class="text" x="50%" y="115%">HTML</text>
        </svg>
      </div>
    </div>
    </div>
    <script type="text/javascript">
      var forEach = function (array, callback, scope) {
        for (var i = 0; i < array.length; i++) {
          callback.call(scope, i, array[i]);
        }
      };
      window.onload = function(){
        var max = -219.99078369140625;
        forEach(document.querySelectorAll('.progress'), function (index, value) {
        percent = value.getAttribute('data-progress');
          value.querySelector('.fill').setAttribute('style', 'stroke-dashoffset: ' + ((100 - percent) / 100) * max);
          value.querySelector('.value').innerHTML = percent + '%';
        });
      }
    </script>
<style>
* {
  padding: 0;
  margin: 0;
  font-weight: 800;
  font-family: 'IBM Plex Sans', sans-serif;
}
.wrapper-center {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}
.progress-bar {
    background: #000;
    width: 200px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px; 
    position: relative;
}
.progress-bar:before {
    content: "";
    position: absolute;
    right: 0;
    width: 50%;
    height: 100%;
    background: #444;
    z-index: 0;
}
/*===== The CSS =====*/
.progress{
    width: 200px;
    height: 280px;
    z-index: 1;
}
.progress .track, .progress .fill{
    fill: rgba(0, 0, 0, 0);
    stroke-width: 3;
    transform: rotate(90deg)translate(0px, -80px);
}
.progress .track{
    stroke: #20313e;
}
.progress .fill {
    stroke: #008eff;
    stroke-dasharray: 219.99078369140625;
    stroke-dashoffset: -219.99078369140625;
    transition: stroke-dashoffset 1s;
}
.progress .value {
    fill: #008eff;
    text-anchor: middle;
}
.progress .text {
    font-size: 12px;
    fill: #fff;
    text-anchor: middle;
}
</style>
  </body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript update text in div 
Javascript :: keyup in jquery 
Javascript :: array concat in javascript 
Javascript :: execcommand javascript 
Javascript :: for loop in shopify liquid template 
Javascript :: express reload page after post 
Javascript :: recursive reverse string 
Javascript :: slice string js 
Javascript :: count using sequelize.fn 
Javascript :: remove item from array javascript 
Javascript :: adding a timer in a quiz game 
Javascript :: angular conditionally show tooltip 
Javascript :: express session mongoose 
Javascript :: mongoose number bigger 
Javascript :: get server side props 
Javascript :: convert json into map in java example 
Javascript :: parseint 
Javascript :: average of numbers 
Javascript :: change class of icon using jquery 
Javascript :: json array in hidden field not coming 
Javascript :: image react 
Javascript :: bcrypt 
Javascript :: set cors for a react node application socket error 
Javascript :: javascript how to get last property of object 
Javascript :: create object from array 
Javascript :: let var 
Javascript :: how to install nide js in ubuntu 
Javascript :: node require fs not found 
Javascript :: logic operators in js 
Javascript :: ndjson to json javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =