css动画水球图

打印 上一主题 下一主题

主题 958|帖子 958|积分 2874

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
由于echarts水球图动画会导致ios卡顿,所以纯css模拟
展示效果

组件
  1. <template>
  2.   <div class="water-box">
  3.     <div class="water">
  4.       <div class="progress" :style="{ '--newProgress': newProgress + '%' }"></div>
  5.       <div class="num">{
  6.   
  7.   { parseFloat(text).toFixed(2) + '%' }}</div>
  8.     </div>
  9.   </div>
  10. </template>
  11. <script>
  12. export default {
  13.   name: 'Water',
  14.   props: {
  15.     progress: {
  16.       type: Number,
  17.       default: 0
  18.     },
  19.     text: {
  20.       type: Number,
  21.       default: 0
  22.     }
  23.   },
  24.   data() {
  25.     return {
  26.       newProgress: 0
  27.     }
  28.   },
  29.   mounted() {
  30.     this.newProgress = this.progress > 100 ? 100 : this.progress
  31.   },
  32.   watch: {
  33.     progress(val) {
  34.       this.newProgress = val > 100 ? 100 : val
  35.     }
  36.   }
  37. }
  38. </script>
  39. <style scoped lang="scss">
  40. .water-box {
  41.   width: 100px;
  42.   height: 100px;
  43.   border-radius: 50%;
  44.   border: 1px solid #4c5259;
  45.   background: linear-gradient(180deg, #171c25 0%, #313741 49.79%, #171c25 100%);
  46.   box-shadow: 0 2px 10px 0 rgba(255, 255, 255, 0.25);
  47.   display: flex;
  48.   align-items: center;
  49.   justify-content: center;
  50.   .water {
  51.     position: relative;
  52.     display: flex;
  53.     justify-content: center;
  54.     align-items: center;
  55.     width: 87.5px;
  56.     height: 87.5px;
  57.     border-radius: 50%;
  58.     &::after {
  59.       content: '';
  60.       position: absolute;
  61.       left: 0;
  62.       right: 0;
  63.       bottom: 0;
  64.       border: 1px solid #313741;
  65.       background: linear-gradient(135deg, #04bdf8 30.52%, #01e7af 100%, #01e4b4 100%);
  66.       border-radius: 50%;
  67.       top: 0;
  68.     }
  69.     .progress {
  70.       width: 100%;
  71.       height: 100%;
  72.       text-align: center;
  73.       color: #fff;
  74.       line-height: 125px;
  75.       position: absolute;
  76.       left: 0;
  77.       top: 0;
  78.       border-radius: 50%;
  79.       z-index: 1;
  80.       overflow: hidden;
  81.       &::before,
  82.       &::after {
  83.         content: '';
  84.         position: absolute;
  85.         left: -50%;
  86.         width: 200px;
  87.         height: 200px;
  88.       }
  89.       &::before {
  90.         background-color: #313741;
  91.         opacity: 0.8;
  92.         border-radius: 40% 30%;
  93.         animation: rotate1 10s linear infinite;
  94.       }
  95.       &::after {
  96.         background-color: #313741;
  97.         opacity: 0.7;
  98.         border-radius: 42% 40%;
  99.         animation: rotate2 10s linear infinite;
  100.       }
  101.     }
  102.     @keyframes rotate1 {
  103.       0% {
  104.         transform: rotate(0deg);
  105.         bottom: var(--newProgress); /*控制进度*/
  106.       }
  107.       100% {
  108.         transform: rotate(360deg);
  109.         bottom: var(--newProgress);
  110.       }
  111.     }
  112.     @keyframes rotate2 {
  113.       0% {
  114.         transform: rotate(45deg);
  115.         bottom: var(--newProgress);
  116.       }
  117.       100% {
  118.         transform: rotate(360deg);
  119.         bottom: var(--newProgress);
  120.       }
  121.     }
  122.     .num {
  123.       z-index: 2;
  124.       color: #fff;
  125.       font-size: 18px;
  126.       font-weight: 500;
  127.     }
  128.   }
  129. }
  130. </style>
复制代码
引用
  1. <water
  2.     :progress="66"
  3.     :text="66"
  4. />
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

大连密封材料

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表