源代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
* {
margin: 0; padding: 0;
}
body {
margin: 200px;
position: relative;
}
.A {
width: 50px; height: 50px;
position: absolute;
}
.A p {
width: 12px; height: 12px;
background: gray;
border-radius: 50%;
position: absolute;
animation: loading 2s infinite linear;
}
.A p:nth-child(1) {
left: 0; top: 0;
animation-delay: -0.1s;
}
.A p:nth-child(2) {
right: 0; top: 0;
animation-delay: -0.5s;
}
.A p:nth-child(3) {
right: 0; bottom: 0;
animation-delay: -0.9s;
}
.A p:nth-child(4) {
left: 0; bottom: 0;
animation-delay: -1.3s;
}
.B {
width: 50px; height: 50px;
position: absolute;
transform: rotate(45deg);
}
.B p {
width: 12px; height: 12px;
background: gray;
border-radius: 50%;
position: absolute;
animation: loading 2s infinite linear;
}
.B p:nth-child(1) {
left: 0; top: 0;
animation-delay: -0.3s;
}
.B p:nth-child(2) {
right: 0; top: 0;
animation-delay: -0.7s;
}
.B p:nth-child(3) {
right: 0; bottom: 0;
animation-delay: -1.1s;
}
.B p:nth-child(4) {
left: 0; bottom: 0;
animation-delay: -1.5s;
}
@-webkit-keyframes loading{
0%{transform: scale(0);}
50%{transform: scale(1);}
100%{transform: scale(0);}
}
</style>
</head>
<body>
<div class="A">
<p></p>
<p></p>
<p></p>
<p></p>
</div>
<div class="B">
<p></p>
<p></p>
<p></p>
<p></p>
</div>
</body>
</html>