html:
<div class="loading"></div>
css:
* {
padding: 0;
margin: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #222;
}
.loading {
position: relative;
width: 150px;
height: 150px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: #9370db;
animation: rotate 2s linear 1 forwards;
}
.loading::before {
content: "";
position: absolute;
top: 5px;
right: 5px;
bottom: 5px;
left: 5px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: #ba55d3;
animation: rotate 3s linear 1 forwards;
}
.loading::after {
content: "";
position: absolute;
top: 15px;
right: 15px;
bottom: 15px;
left: 15px;
border-radius: 50%;
border: 3px solid transparent;
border-top-color: #f0f;
/* 动画 时长 linear是匀速运动 infinite 是无限次运动 */
animation: rotate 1.5s linear 1 forwards;
}
/* 下面定义一下动画 */
@keyframes rotate {
0% {
transform: rotate(0);
}
100% {
/* 顺时针旋转360度 */
transform: rotate(360deg);
opacity: 0;
visibility: hidden;
z-index: -1;
}
}