barre de progrès circulaire 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>
Splendid Sable