当前位置: 首页 > news >正文

css,环形

思路:
1.先利用conic-gradient属性画一个圆,然后再叠加
效果图

在这里插入图片描述

<template><div class="ring"><div class="content"><slot></slot></div></div>
</template>
<script>
import { defineComponent, reactive, toRefs, computed, onMounted } from "vue";
export default defineComponent({props: {width: {type: Number,default: 200,},height: {type: Number,default: 200,},color: {type: String,default: "#fcb844",},angle: {type: Number,default: 360,},total: {type: Number,default: 360,},unit: {type: String,default: "px",},interval: {type: Number,default: 20,},autoPlay: {type: Boolean,default: true,},},setup(props, { emit }) {const datas = reactive({timer: null,sportAge: 0,});// 设置渐变const bgImage = computed(() => {datas.sportAge = props.autoPlay ? datas.sportAge : currentAngle.value;return `conic-gradient(${props.color} 0deg, ${props.color} ${datas.sportAge}deg, transparent 0deg)`;});// 当前度数(deg)const currentAngle = computed(() => {return ((360 / props.total) * props.angle).toFixed(2);});// 单位前缀const unitSuffix = computed(() => {return (data, interval = 0) => {return data - interval + props.unit;};});//动画const animationPlay = () => {datas.timer = setInterval(() => {if (currentAngle.value <= datas.sportAge) {clearInterval(datas.timer);datas.timer = null;return;}datas.sportAge++;}, 10);};onMounted(() => {props.autoPlay ? animationPlay() : "";});return {...toRefs(datas),bgImage,unitSuffix,};},
});
</script>
<style lang="less" scoped>
.ring {position: relative;width: v-bind(unitSuffix(width));height: v-bind(unitSuffix(height));display: flex;align-items: center;justify-content: center;&::before {content: "";position: absolute;left: 0;top: 0;width: v-bind(unitSuffix(width));height: v-bind(unitSuffix(height));// background-color: red; /* 对于不支持渐变的浏览器 */background-image: v-bind(bgImage);border-radius: 50%;transform: scale(-1, 1);}&::after {content: "";position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);width: v-bind(unitSuffix(width, interval));height: v-bind(unitSuffix(height, interval));border-radius: 50%;background-color: #ffffff;}.content {position: absolute;z-index: 3;width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;}
}
</style>
<template><div class="ring_box"><div class="inner"><ring:width="180":height="180":color="innerColor":z-index="2":interval="interval"></ring><div class="out"><ring :total="3454" :angle="2234" :interval="interval" :z-index="4"><ring:width="175":height="175":color="innerColor":interval="interval / 2":z-index="4"><div>内容</div></ring></ring></div></div></div>
</template>
<script lang="ts">
import ring from "./ring.vue";
import { defineComponent, reactive, toRefs } from "vue";
export default defineComponent({components: {ring,},setup(props) {const datas = reactive({width: 180,height: 180,outColor: "",innerColor: "#feedd1",interval: 40,});return {...toRefs(datas),};},
});
</script>
<style lang="less" scoped>
.ring_box {width: 300px;height: 300px;display: flex;align-items: center;justify-items: center;position: relative;.out,.inner {position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);}
}
</style>
http://www.lryc.cn/news/174419.html

相关文章:

  • php食堂点餐系统hsg5815ABA2程序-计算机毕业设计源码+数据库+lw文档+系统+部署
  • Vite打包时使用plugin解决浏览器兼容问题
  • java Excel 自用开发模板
  • 34.CSS魔线图标的悬停效果
  • Django — 会话
  • SpringBoot集成easypoi实现execl导出
  • 第9章 【MySQL】InnoDB的表空间
  • 工作、生活常用免费api接口大全
  • 寻找单身狗
  • 【pytest】 allure 生成报告
  • 动态链接库搜索顺序
  • 【CAN、LIN通信的区分】
  • Redis环境配置
  • UG NX二次开发(C++)-采用std::vector对体对象的质心进行排序
  • 一点思考|关于「引领性研究」的一点感悟
  • 什么是HTTP/2?它与HTTP/1.1相比有什么改进?
  • IDEA
  • NSS [HXPCTF 2021]includer‘s revenge
  • 《动手学深度学习 Pytorch版》 7.1 深度卷积神经网络(AlexNet)
  • C++ - 双指针_盛水最多的容器
  • 分类预测 | Matlab实现NGO-CNN-SVM北方苍鹰算法优化卷积支持向量机分类预测
  • 分享一个java+springboot+vue校园电动车租赁系统(源码、调试、开题、lw)
  • 高性能计算环境下的深度学习异构集群建设与优化实践
  • Laravel框架 - Facade门面
  • 算法通关村第16关【青铜】| 滑动窗口思想
  • CentOS安装openjdk和elasticsearch
  • 【新版】系统架构设计师 - 案例分析 - 信息安全
  • 数据库设计(火车订票系统)
  • qemu+docker在服务器上搭建linux内核调试环境
  • Stable Diffusion 参数介绍及用法