console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>超炫Loading动画</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="main">
<div class="container">
<div class="circle">
<span style="--i:0;"></span>
<span style="--i:1;"></span>
<span style="--i:2;"></span>
<span style="--i:3;"></span>
<span style="--i:4;"></span>
<span style="--i:5;"></span>
<span style="--i:6;"></span>
<span style="--i:7;"></span>
<span style="--i:8;"></span>
<span style="--i:9;"></span>
<span style="--i:10;"></span>
<span style="--i:11;"></span>
<span style="--i:12;"></span>
<span style="--i:13;"></span>
<span style="--i:14;"></span>
<span style="--i:15;"></span>
<span style="--i:16;"></span>
<span style="--i:17;"></span>
<span style="--i:18;"></span>
<span style="--i:19;"></span>
<span style="--i:20;"></span>
</div>
<div class="circle">
<span style="--i:0;"></span>
<span style="--i:1;"></span>
<span style="--i:2;"></span>
<span style="--i:3;"></span>
<span style="--i:4;"></span>
<span style="--i:5;"></span>
<span style="--i:6;"></span>
<span style="--i:7;"></span>
<span style="--i:8;"></span>
<span style="--i:9;"></span>
<span style="--i:10;"></span>
<span style="--i:11;"></span>
<span style="--i:12;"></span>
<span style="--i:13;"></span>
<span style="--i:14;"></span>
<span style="--i:15;"></span>
<span style="--i:16;"></span>
<span style="--i:17;"></span>
<span style="--i:18;"></span>
<span style="--i:19;"></span>
<span style="--i:20;"></span>
</div>
</div>
</div>
</body>
</html>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 背景 */
.main{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: cadetblue;
animation: animateColor 8s linear infinite;
}
/* 背景色变化 */
@keyframes animateColor {
0%{
filter: hue-rotate(0deg);
}
100%{
filter: hue-rotate(360deg);
}
}
/* 内容宽 */
.main .container{
display: flex;
}
/* 盒子-圆 */
.main .container .circle{
position: relative;
width: 150px;
height: 150px;
margin: 0 -8px;
}
/* 盒子-点 */
.main .container .circle span{
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
/* 通过旋转将 点 画一个圆 */
transform: rotate( calc( 360deg / ( 21 - 1 ) * var(--i) ));
}
/* 每一个点 */
.main .container .circle span::before{
content: '';
position: absolute;
right: 0;
top: calc( 50% - 7.5px );
width: 15px;
height: 15px;
background-color: antiquewhite;
border-radius: 50%;
/* 发光效果 */
box-shadow: 0 0 10px antiquewhite,
0 0 20px antiquewhite,
0 0 40px antiquewhite,
0 0 60px antiquewhite,
0 0 80px antiquewhite,
0 0 100px antiquewhite;
/* 通过 大小变化 体现加载 */
transform: scale(0.1);
/* 动画设置 */
animation: animate calc( ( 0.1s * ( 21 - 1 ) ) * 2 ) linear infinite;
animation-delay: calc( 0.1s * var(--i) );
}
@keyframes animate {
0%{
transform: scale(1);
}
50%,100%{
transform: scale(0.1);
}
}
/* 设置第二个的延迟 和 初始位置 */
.main .container .circle:nth-child(2){
transform: rotate(-180deg);
}
.main .container .circle:nth-child(2) span::before{
animation-delay: calc( -0.1s * var(--i) );
}