纯CSS圆形进度条(原创)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>纯CSS圆形进度条</title>
<style>
* {
padding: 0;
margin: 0;
}
div {
box-sizing: border-box;
}
.main {
padding-top: 80px;
}
.title {
text-align: center;
}
.box {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
justify-content: space-around;
padding-top: 80px;
margin: 0 auto;
}
.demost1,
.demost2 {
margin-bottom: 94px;
}
.demost1 {
width: 300px !important;
height: 300px !important;
}
.demost1 .percentage {
width: 260px !important;
height: 260px !important;
}
.demost2 {
width: 500px !important;
height: 500px !important;
}
.demost2 .percentage {
width: 420px !important;
height: 420px !important;
}
</style>
<!-- 组件样式 -->
<style>
.panClip {
width: 400px;
height: 400px;
background-color: #ccc;
border-radius: 50%;
position: relative;
overflow: hidden;
}
.panClip .percentage {
width: 280px;
height: 280px;
font-size: 32px;
color: #333;
background-color: #fff;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
transform: translate(-50%, -50%);
position: absolute;
top: 50%;
left: 50%;
z-index: 5;
}
.panClip .clipBox {
width: 100%;
height: 100%;
position: absolute;
border-radius: 50%;
clip-path: polygon(50% 0%, 50% 100%, 100% 100%, 100% 0%);
}
.panClip .clipBox .clipLeft,
.panClip .clipBox .clipRight {
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #0bd35b;
position: absolute;
top: 0px;
left: 0px;
}
.panClip .clipBox .clipLeft {
clip-path: polygon(0% 0%, 0% 100%, 50% 100%, 50% 0%);
}
.panClip .clipBox .clipRight {
clip-path: polygon(50% 0%, 50% 100%, 100% 100%, 100% 0%);
}
.width-none {
width: 0 !important;
}
.clip_none {
clip-path: none !important;
}
.panClip .circular {
display: none;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #0bd35b;
transform: translateX(-50%);
position: absolute;
top: 0px;
left: 50%;
z-index: 3;
}
.panClip .corest {
width: 100%;
height: 100%;
position: absolute;
}
</style>
</head>
<body>
<div class="main">
<h1 class="title">纯CSS圆形进度条</h1>
<div class="box">
<div class="panClip demost1">
<div class="clipBox">
<div class="clipLeft"></div>
<div class="clipRight width-none"></div>
</div>
<div class="percentage">0%</div>
<div class="circular"></div>
<div class="corest">
<div class="circular"></div>
</div>
</div>
<div class="panClip demost2">
<div class="clipBox">
<div class="clipLeft"></div>
<div class="clipRight width-none"></div>
</div>
<div class="percentage">0%</div>
<div class="circular"></div>
<div class="corest">
<div class="circular"></div>
</div>
</div>
</div>
</div>
<script src="https://www.jq22.com/jquery/jquery-3.3.1.js"></script>
<script src="https://www.jq22.com/demo/jdt202212252317/panClip.js"></script>
<script>
let demost1 = $('.demost1').eq(0);//获取自定义类名
let demost2 = $('.demost2').eq(0);
setTimeout(() => {
panClip(demost1, 42, 'red');
panClip(demost2, 65);
}, 500);
</script>
</body>
</html>
页:
[1]