实现了一个简单的加载动画效果,包括一个圆形的加载器,它由三个不同颜色的圆环组成,每个圆环都沿着圆形路径旋转。这个加载器是通过使用CSS动画和伪元素来实现的。背景色为黑色。
实现代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>彩虹旋转加载</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #212121;
}
.loader {
width: 200px;
height: 200px;
position: relative;
border-radius: 50%;
border: 4px solid transparent;
border-top-color: #4bc0c8;
animation: spin 2s linear infinite;
}
.loader::before {
content: "";
position: absolute;
left: 5px;
top: 5px;
right: 5px;
bottom: 5px;
border-radius: 50%;
border: 4px solid transparent;
border-top-color: #c779d0;
animation: spin 3s linear infinite;
}
.loader::after {
content: "";
position: absolute;
left: 15px;
top: 15px;
right: 15px;
bottom: 15px;
border-radius: 50%;
border: 4px solid transparent;
border-top-color: #feac5e;
animation: spin 1.5s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="loader"></div>
</body>
</html>
HTML