<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>preloader animation</title>
</head>
<body>
<div class="loader">
<span></span>
<span></span>
<span></span>
</div>
</body>
</html>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
CSS
格式化
body
{
margin: 0;
padding: 0;
background: #bd2ae2;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.loader
{
width: 150px;
height: 150px;
position: relative;
}
span
{
position: absolute;
width: 50px;
height: 50px;
background-color:white;
border-radius: 4px;
animation: chase 2s linear infinite;
}
span:nth-child(2)
{
animation-delay: 0.7s;
}
span:nth-child(1)
{
animation-delay: 1.4s;
}
@keyframes chase
{
0% {top: 0; left: 0;}
12.5% { top: 0; left: 50%;}
25% { top: 0; left: 50%;}
37.5% { top: 50%; left: 50%;}
50% { top: 50%; left: 50%;}
62.5% { top: 50% ; left: 0;}
75% { top: 50% ; left: 0;}
82.5% { top: 0; left: 0;}
100% { top: 0; left: 0;}
}
JS
格式化