纯css实现蒙层loading效果

时间:2022-11-01 03:30:54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<style>
.span{
position: absolute;
top: 0;
left: 0;
width: 100%;
background: rgba(0,0,0,0.4);
height:100%;
vertical-align: middle;
border-radius: 1px;
display:none
}
.help{
width:1rem;
height: 1rem;
border: .05rem #fff solid;
border-radius: 50%;
-webkit-animation: rotation 1s ease-in-out infinite;
-moz-animation: rotation 1s ease-in-out infinite;
animation: rotation 1s ease-in-out infinite;
position: absolute;
top:50%;
left:50%;
margin-top:-.5rem;
margin-left:-.5rem;
}
.help:after{
width: .15rem;
height: .15rem;
background-color: #fff;
border-radius: 100%;
position: absolute;
content: "";
left:.06rem;
top:.1rem; }
@-webkit-keyframes rotation{
0%{-webkit-transform: rotate(0deg);}
100%{-webkit-transform: rotate(360deg);}
}
@-moz-keyframes rotation{
0%{-moz-transform: rotate(0deg);}
100%{-moz-transform: rotate(360deg);}
}
@keyframes rotation{
0%{transform: rotate(0deg);}
100%{transform: rotate(360deg);}
}
</style>
</head>
<body>
<div><button id="test" >点击</button></div>
<div class="span">
<div class="help"></div>
</div>
<script>
$("#test").click(function () {
$('.span').show();
}) </script>
</body>
</html>