效果视频展示:
【html+css】小方块等待动效
全部代码(放心粘贴):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>等待动效</title>
</head>
<style>
*{
margin: 0;
padding: 0;
}
html{
height: 100%;
}
body{
background: rgb(192, 192, 248);
}
.box{
position: absolute;
width: 796px;
height: 296px;
top: 50%;
margin-top: -150px;
left: 50%;
margin-left: -400px;
border: 2px solid black ;
border-radius: 20px;
}
.box>div{
position: absolute;
width: 232px;
height: 256px;
margin-top: 20px;
margin-left: 10px;
background: white;
border-radius: 30px;
display: flex;
justify-content: center;
align-items: center;
}
.box>div:nth-child(1){
transform: scale(0.8);
animation: divB 3s 0s infinite;
}
.box>div:nth-child(2){
left: 272px;
animation: divF 3s 0s infinite;
}
.box>div:nth-child(3){
left: 544px;
transform: scale(0.8);
animation: divB 3s 0s infinite;
}
@keyframes divF {
0%{
background: linear-gradient(to right, rgb(118, 118, 255),rgb(126, 126, 230));
transform: scale(0.8);
}
50%{
background: linear-gradient(to right, rgb(174, 0, 255) ,rgb(120, 120, 252));
transform: scale(1);
}
100%{
background: linear-gradient(to right, rgb(112, 112, 255),rgb(174, 0, 255));
transform: scale(0.8);
}
}
@keyframes divB {
0%{
background:linear-gradient(to right,rgb(174, 0, 255),rgb(115, 115, 247));
transform: scale(1);
}
50%{
background:linear-gradient(to right,rgb(112, 112, 243),rgb(174, 0, 255));
transform: scale(0.8);
}
100%{
background:linear-gradient(to right,rgb(126, 126, 230),rgb(174, 0, 255));
transform: scale(1);
}
}
</style>
<body>
<div class="box">
<div></div>
<div></div>
<div></div>
</div>
</body>
</html>