1. 效果如下
代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>loading-animate</title>
<style>
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(75deg);
width: 15px;
height: 15px;
}
.loading::before,
.loading::after {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 15px;
height: 15px;
border-radius: 15px;
animation: loading 1.5s infinite linear;
}
.loading::before {
/* 相对于.loading偏移15px */
box-shadow: 15px 15px #ef5b9c, -15px -15px #f47920;
}
.loading::after {
box-shadow: 15px 15px #5c7a29, -15px -15px #009ad6;
/* 使用transform调整::after的位置 */
transform: translate(-50%, -50%) rotate(90deg);
}
@keyframes loading {
50% {
width: 45px;
}
}
</style>
</head>
<body>
<div class="loading"></div>
</body>
</html>
转载至:https://www.bilibili.com/video/BV1m7411Y76c