CSS3三:(animation動畫-案例人物走路動畫)
阿新 • • 發佈:2018-12-08
CSS3 animation動畫
1、@keyframes 定義關鍵幀動畫 2、animation-name 動畫名稱 3、animation-duration 動畫時間 4、animation-timing-function 動畫曲線 linear(勻速)|ease(緩衝)|steps(步數) 5、animation-delay 動畫延遲 6、animation-iteration-count 動畫播放次數 n|infinite 7、animation-direction 動畫結束後是否反向還原 normal|alternate 8、animation-play-state 動畫狀態 paused(停止)|running(運動)
案例 人物走路動畫
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title >走路動畫</title>
<style type="text/css">
.box{
width:120px;
height:180px;
border:1px solid #ccc;
margin:50px auto 0;
position:relative;
overflow:hidden;
}
.box img {
display:block;
width:960px;
height:182px;
position: absolute;
left:0;
top:0;
animation:walking 1.0s steps(8) infinite;
}
@keyframes walking{
from{
left:0px;
}
to{
left:-960px;
}
}
</style>
</head>
<body>
<div class="box"><img src="images/walking.png"></div>
</body>
</html>