css+svg实现彩色圆环进度动画效果代码

代码语言:html

所属分类:响应式

代码描述:css+svg实现彩色圆环进度动画效果代码

代码标签: css svg 彩色 圆环 进度 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  
  
<style>
html {
  --page-background: #fff;
  --line-background: #eee;
}

.graph circle.one {
  --color: blue;
  --value: 3;
  --max: 4;
}

.graph circle.two {
  --color: teal;
  --value: 4;
  --max: 6;
}

.graph circle.three {
  --color: rebeccapurple;
  --value: 6;
  --max: 7;
}

.graph circle.four {
  --color: green;
  --value: 30;
  --max: 100;
}

.graph circle.five {
  --color: orange;
  --value: 4;
  --max: 10;
}

.graph circle.six {
  --color: orangered;
  --value: 7;
  --max: 10;
}

body {
  margin: 0;
  display: grid;
  place-content: center;
  height: 100vh;
  background: var(--page-background, white);
}

svg {
  width: 90vmin;
  height: 90vmin;
}

circle {
  fill: none;
  stroke: var(--color, red);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: calc(100px * var(--value, 0) / var(--max, 100)) 100;
  transform: rotate(90deg);
  transform-origin: 50% 50%;
}
.background circle {
  stroke: var(--line-background, white);
  stroke-width: 5;
  stroke-dasharray: none;
}
.graph circle {
  -webkit-animation: circle 2s ease-in-out both;
          animation: circle 2s ease-in-out both;
}

@-webkit-keyframes circle {
  0% {
    opacity: 0;
    stroke-dasharray: 0 100;
  }
}

@keyframes circle {
  0% {
    opacity: 0;
    stroke-dasharray: 0 100;
  }
}
circle:nth-child(1) {
  --color: hsl(0 100% 48%);
  -webkit-animation-delay: 1s;
          animation-delay: 1s;
}

circle:nth-child(2) {
  --color: hsl(40 100% 48%);
  -webkit-animation-delay: 0.8s;
          animation-delay: 0.8s;
}

circle:nth-child(3) {
  --color: hsl(80 100% 48%);
  -webkit-animation-delay: 0.6s;
          animation-delay: 0.6s;
}

circle:nth-child(4) {
  --color: hsl(120 100% 48%);
  -webkit-animation-delay: 0..........完整代码请登录后点击上方下载按钮下载查看

网友评论0