css loading动画
时间: 2023-11-21 07:55:49 浏览: 147
以下是两个使用CSS实现的loading动画:
1. 经典款loading动画,只需一个div元素即可完成:
```css
.loader-6 {
width: 48px;
height: 48px;
border: 2px solid #FFF;
border-radius: 50%;
display: inline-block;
position: relative;
-webkit-animation: rotation 1s linear infinite;
animation: rotation 1s linear infinite;
}
.loader-6:after {
content: "";
position: absolute;
left: 50%;
top: 0;
background: #FF3D00;
width: 3px;
height: 24px;
transform: translateX(-50%);
}
@-webkit-keyframes rotation {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
@keyframes rotation {
from {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
```
2. loader-7动画,使用多个div元素实现:
```css
.loader-7 {
width: 40px;
height: 40px;
display: flex;
justify-content: space-between;
align-items: center;
}
.loader-7 div {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: #FF3D00;
animation: loader-7 1s ease-in-out infinite;
}
.loader-7 div:nth-child(1) {
animation-delay: 0s;
}
.loader-7 div:nth-child(2) {
animation-delay: 0.1s;
}
.loader-7 div:nth-child(3) {
animation-delay: 0.2s;
}
.loader-7 div:nth-child(4) {
animation-delay: 0.3s;
}
.loader-7 div:nth-child(5) {
animation-delay: 0.4s;
}
.loader-7 div:nth-child(6) {
animation-delay: 0.5s;
}
.loader-7 div:nth-child(7) {
animation-delay: 0.6s;
}
.loader-7 div:nth-child(8) {
animation-delay: 0.7s;
}
@keyframes loader-7 {
0% {
transform: scale(1);
}
20% {
transform: scale(1, 2.5);
}
40% {
transform: scale(1);
}
}
```
阅读全文