您的位置:首页 > Web前端 > CSS

CSS实现loading加载效果

2017-08-24 08:32 573 查看
body部分代码:

<div class="loading">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>


CSS部分代码:

.loading{
width: 50px;
height: 50px;
position: relative;
margin: 0 auto;
margin-top:100px;
}
.loading span{
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
background: #ddd;
position: absolute;
-webkit-animation: load 1.04s ease infinite;
}
@-webkit-keyframes load{
0%{
opacity: 1;
}
100%{
opacity: 0.2;
}
}
.loading span:nth-child(1){
left: 0;
top: 50%;
margin-top:-4px;
-webkit-animation-delay:0.13s;
}
.loading span:nth-child(2){
left: 7px;
top: 7px;
-webkit-animation-delay:0.26s;
}
.loading span:nth-child(3){
left: 50%;
top: 0;
margin-left: -4px;
-webkit-animation-delay:0.39s;
}
.loading span:nth-child(4){
top: 7px;
right:7px;
-webkit-animation-delay:0.52s;
}
.loading span:nth-child(5){
right: 0;
top: 50%;
margin-top:-4px;
-webkit-animation-delay:0.65s;
}
.loading span:nth-child(6){
right: 7px;
bottom:7px;
-webkit-animation-delay:0.78s;
}
.loading span:nth-child(7){
bottom: 0;
left: 50%;
margin-left: -4px;
-webkit-animation-delay:0.91s;
}
.loading span:nth-child(8){
bottom: 7px;
left: 7px;
-webkit-animation-delay:1.04s;
}


这样就可得到如图的效果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息