<!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>
<style>
body{
width: 100vw;
height: 100vh;
display: flex;
justify-content:center;
align-items:flex-end;
background: url(img/780.jpg) 0 -100px;
}
.box{
width: 350px;
height: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.ball{
width: 100px;
height:100px;
background: url("img/782.jpg");
background-size: 100px 100px;
border-radius: 100%;
animation: move 1s infinite alternate; /*infinite无限循环,alternate动画反向执行回到起点*/
}
/*小球跳动的动画*/
@keyframes move{
from{
transform: translateY(0) rotate(0);
}
to{
transform: translateY(-350px) rotate(-360deg);
}
}
.shadow{
width:150px;
height: 40px;
background-color: #000;
border-radius: 100%;
opacity: 0.5;
margin-top: -10px;
animation: shadowMove 1s infinite alternate; /*infinite无限循环,alternate动画反向执行回到起点*/
}
/*阴影变化的动画*/
@keyframes shadowMove{
0%{
opacity: 0.5;
transform: scale(0.75);
}
100%{
opacity: 0.2;
transform: scale(1);
}
}
/* 第二个球动画延迟0.2秒 */
.second .ball,.second .shadow{
animation-delay: 0.2s;
}
/* 第三个球动画延迟0.5秒 */
.thrid .ball,.thrid .shadow{
animation-delay: 0.5s;
}
</style>
</head>
<body>
<div class="box">
<div class="ball"></div>
<div class="shadow"></div>
</div>
<div class="box second">
<div class="ball"></div>
<div class="shadow"></div>
</div>
<div class="box thrid">
<div class="ball"></div>
<div class="shadow"></div>
</div>
</body>
</html>
|