<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.loading-css {
width: 50px;
/*先将loading区域变成正方形*/
height: 50px;
display: inline-block;
/*将loading区域变成行内元素,防止旋转的时候,100%宽度都在旋转*/
border: 3px solid #f3f3f3;
/*设置四周边框大小,并将颜色设置为浅白色*/
border-top: 3px solid red;
/*将上边框颜色设置为红色高亮,以便旋转的时候能够看到旋转的效果*/
border-radius: 50%;
/*将边框和内容区域都变成圆形*/
}
@keyframes loading-360 {
0% {
transform: rotate(0deg);
/*动画起始的时候旋转了0度*/
}
100% {
transform: rotate(360deg);
/*动画结束的时候旋转了360度*/
}
}
.loading-css {
/*在之前的CSS中加上动画效果即可*/
animation: loading-360 0.8s infinite linear;
/*给圆环添加旋转360度的动画,并且是无限次*/
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.cover {
position: fixed;
z-index: 99999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .2);
}
</style>
<body>
<div class="cover">
<div class="loading-css"></div>
</div>
</body>
<script>
</script>
</html>