先来看看效果
css部分
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
height: 100vh;
padding-bottom: 80px;
background-color: #000;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.loading{
width: 300px;
height: 300px;
background-color: #000;
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.loading span{
width: 30px;
height: 30px;
background-color: #fff;
border-radius: 50%;
position: absolute;
left: 50px;
transform-origin: 100px center;
transform: rotate(
calc(360deg/8*var(--i))
);
}
@keyframes show {
0%{
transform: rotate(0deg) translateX(80px);
}
50%,100%{
transform: rotate(
calc(360deg/8*var(--i))
);
}
100%{
transform: rotate(360deg) translateX(80px);
}
}
.loading span{
animation:show 3s infinite;
}
.loading{
filter: contrast(15);
}
.text{
font-size: 50px;
color: #fff;
padding-left: 10px;
display: flex;
}
@keyframes text {
0%{
transform: translateY(0px);
}
20%{
transform: translateY(-24px);
}
40%,100%{
transform: translateY(0px);
}
}
.text span{
animation: text 1.5s ease-in-out infinite;
animation-delay: calc(.1s * var(--i));
}
</style>
html部分
<body>
<div class="loading">
<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>
</div>
<div class="text">
<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>
</div>
</body>