前端环形拖尾进度条
效果图
直接上代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>环形拖尾进度条</title>
</head>
<style>
.loading {
width: 80px;
height: 80px;
border-radius: 50%;
position: relative;
padding: 10px;
}
.loading-content {
width: 80px;
height: 80px;
background-color: #ffffff;
position: relative;
z-index: 90;
border-radius: 50%;
}
.text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 18px;
}
.loading-border {
width: 80px;
height: 80px;
position: absolute;
top: 0;
left: 0;
z-index: 50;
border: 10px solid #f1f1f1;
border-radius: 50%;
}
.loading-mask {
width: 100%;
height: 100%;
position: absolute;
border-radius: 50%;
top: 0;
left: 0;
z-index: 60;
animation: rotateAnimate 1.4s linear infinite;
}
.loading-mask::before {
content: "";
display: block;
position: absolute;
bottom: 0;
left: calc(50% - 5px);
width: 10px;
height: 10px;
z-index: 100;
border-radius: 50%;
background-color: #6082e0;
}
.loading-mask::after {
content: "";
display: block;
position: absolute;
bottom: 0;
left: 50%;
width: 50%;
height: 50%;
border-radius: 0 0 60px 0;
background-image: linear-gradient(46deg, #6082e0, #f1f1f1);
}
@keyframes rotateAnimate {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
</style>
<body>
<div class="loading">
<div class="loading-mask">
<!-- 旋转主体 -->
</div>
<div class="loading-border"></div>
<div class="loading-content">
<div class="text">0%</div>
</div>
</div>
<script>
var text = 0;
var numElement = document.querySelector(".text")
var time = setInterval(()=>{
text++
numElement.innerHTML = text+"%"
if(text==100){
clearInterval(time)
}
},200)
</script>
</body>
</html>