<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1{
width: 100px;
height: 100px;
border-radius: 50%;
background-color: tomato;
animation-name: ball;
animation-duration: 3s;
/* 最后听到to所在的目标处 */
animation-fill-mode: forwards;
/* animation-timing-function: ease-in; */
}
.outer{
height: 500px;
border-bottom: 10px black solid;
margin: 50px auto;
overflow: hidden;
}
/* 创建小球下落的效果 */
@keyframes ball {
from{
margin-top: 0px;
/* 从margin-top:0px加速到20%时的margin-top:400px */
animation-timing-function: ease-in;
}
/* 插入关键帧 */
20%{
margin-top: 400px;
/* 从margin-top:400px减速到40%时的margin-top:200px */
animation-timing-function: ease-out;
}
40%{
margin-top: 200px;
/* 从margin-top:200px加速到60%时的margin-top:400px */
animation-timing-function: ease-in;
}
60%{
margin-top: 400px;
/* 从margin-top:400px减速到40%时的margin-top:300px */
animation-timing-function: ease-out;
}
80%{
margin-top: 300px;
/* 从margin-top:300px加速到20%时的margin-top:400px */
animation-timing-function: ease-in;
}
to{
margin-top: 400px;
}
}
</style>
</head>
<body>
<div class="outer">
<div class="box1"></div>
</div>
</body>
</html>
24动画-关键帧——html
最新推荐文章于 2024-07-25 11:52:08 发布