实例4
- 父元素嵌套子元素双层动画
<div class="animation4">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
.animation4 {
width: 200px;
height: 200px;
position: absolute;
animation: loading4_1 5s linear infinite;
}
.animation4 div {
width: 30px;
height: 30px;
position: absolute;
background: #bea9d9;
animation: loading4_2 2s ease-out infinite;
}
.animation4 div:nth-child(1) {
left: 0;
top: 0;
}
.animation4 div:nth-child(2) {
left: 200px;
top: 0;
}
.animation4 div:nth-child(3) {
left: 0;
top: 200px;
}
.animation4 div:nth-child(4) {
left: 200px;
top: 200px;
}
@keyframes loading4_1 {
100% {
transform: rotate(360deg);
}
}
@keyframes loading4_2 {
50% {
width: 10px;
height: 10px;
background: #4ee9d3;
border-radius: 50%;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
实例5
- 利用为元素实现动画
<div class="animation5"></div>
.animation5 {
position: relative;
width: 100px;
height: 40px;
background: rgba(190, 169, 217, 0.5);
overflow: hidden;
}
.animation5::before {
content: "LOADING";
color: #fff;
line-height: 40px;
text-align: center;
position: absolute;
width: 100px;
height: 40px;
left: -100px;
top: 0;
background: #bea9d9;
animation: loading5 3s linear infinite alternate;
}
@keyframes loading5 {
100% {
left: 0;
}
}
实例6
- 进度条动画效果
<div class="animation6">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
.animation6 {
position: relative;
width: 150px;
height: 40px;
background: rgba(190, 169, 217, 1);
overflow: hidden;
}
.animation6::before {
content: "";
color: #fff;
line-height: 40px;
text-align: center;
position: absolute;
width: 150px;
height: 40px;
left: -150px;
top: 0;
background: #bea9d9;
animation: loading6 6s linear infinite alternate;
}
.animation6 div {
float: left;
margin-right: 10px;
height: 40px;
width: 10px;
background: rgba(255, 255, 255, 0.5);
}
.animation6 div:last-child {
margin-right: 0;
}
@keyframes loading6 {
100% {
left: 150px;
}
}