使用css3制作好看的加载特效
效果图
<div class="father">
<div id="text">loading....</div>
<div class="son1"></div>
<div class="son2"></div>
<div class="son3"></div>
<div class="son4"></div>
<div class="son5"></div>
</div>
具体的思路就是小球在侧面由浅到深,由小到大,跑到中心,原地缩小,然后跑到另一面慢慢变浅变大
body{
background-color: #2196F3;
}
.father{
height:50px;
width: 700px;
/* border: 1px solid red; */
margin: 0 auto;
position: relative;
top: 400px;
line-height: 100px;
}
/* 第一个圆球的动画 */
@keyframes load1 {
0%{
width: 15px;
height: 15px;
top: 20px;
left: 60px;
opacity: 0.2;
}
40%{
width: 25px;
height: 25px;
top: 20px;
left: 440px;
opacity: 1;
}
60%{
width: 15px;
height: 15px;
top: 20px;
left:440px;
opacity: 1;
}
100%{
width: 25px;
height: 25px;
top: 20px;
left: 700px;
opacity: 0;
}
}
/* 第一个圆球 */
.son1{
width: 0px;
height: 0px;
border-radius: 50%;
/* border: 1px solid red; */
background-color: white;
position: absolute;
animation: load1 4s ease-in-out 0s infinite;
/* animation-play-state: paused; */
}
/* 第二个圆球的动画 */
@keyframes load2 {
0%{
width: 15px;
height: 15px;
top: 20px;
left: 30px;
opacity: 0.2;
}
42%{
width: 25px;
height: 25px;
top: 20px;
left: 400px;
opacity: 1;
}
62%{
width: 15px;
height: 15px;
top: 20px;
left: 400px;
opacity: 1;
}
100%{
width: 25px;
height: 25px;
top: 20px;
left: 670px;
opacity: 0;
}
}
/* 第二个圆球 */
.son2{
width: 0px;
height: 0px;
border-radius: 50%;
/* border: 1px solid red; */
background-color: white;
position: absolute;
animation: load2 4s ease-in-out 0.2s infinite;
/* animation-play-state: paused; */
}
/* 第三个圆球的动画 */
@keyframes load3 {
0%{
width: 15px;
height: 15px;
top: 20px;
left: 0px;
opacity: 0.2;
}
44%{
width: 25px;
height: 25px;
top: 20px;
left: 360px;
opacity: 1;
}
64%{
width: 15px;
height: 15px;
top: 20px;
left: 360px;
opacity: 1;
}
100%{
width: 25px;
height: 25px;
top: 20px;
left: 640px;
opacity: 0;
}
}
/* 第三个圆球 */
.son3{
width: 0px;
height: 0px;
border-radius: 50%;
/* border: 1px solid red; */
background-color: white;
position: absolute;
animation: load3 4s ease-in-out 0.4s infinite ;
/* animation-play-state: paused; */
}
/* 第四个圆球的动画 */
@keyframes load4{
0%{
width: 15px;
height: 15px;
top: 20px;
left: -30px;
opacity: 0.2;
}
46%{
width: 25px;
height: 25px;
top: 20px;
left:320px;
opacity: 1;
}
66%{
width: 15px;
height: 15px;
top: 20px;
left: 320px;
opacity: 1;
}
100%{
width: 25px;
height: 25px;
top: 20px;
left: 610px;
opacity: 0;
}
}
/* 第四个圆球 */
.son4{
width: 0px;
height: 0px;
border-radius: 50%;
/* border: 1px solid red; */
background-color: white;
position: absolute;
animation: load4 4s ease-in-out 0.6s infinite;
/* animation-play-state: paused; */
}
/* 第五个圆球的动画 */
@keyframes load5{
0%{
width: 15px;
height: 15px;
top: 20px;
left: -60px;
opacity: 0.2;
}
48%{
width: 25px;
height: 25px;
top: 20px;
left:280px;
opacity: 1;
}
68%{
width: 15px;
height: 15px;
top: 20px;
left: 280px;
opacity: 1;
}
100%{
width: 25px;
height: 25px;
top: 20px;
left: 580px;
opacity: 0;
}
}
/* 第五个圆球 */
.son5{
width: 0px;
height: 0px;
border-radius: 50%;
/* border: 1px solid red; */
background-color: white;
position: absolute;
animation: load5 4s ease-in-out 0.8s infinite;
/* animation-play-state: paused; */
}
注意
****每个圆球的动画之间要有1s的间隔才会有那种小球不间断的效果