使用 CSS 先反向再正向執行動畫
使用 animation-direction 屬性先反向然後正向執行動畫。該屬性與 alternate-reverse 動畫值一起使用來實現此目的。
示例
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 150px;
height: 200px;
position: relative;
background-color: yellow;
animation-name: myanim;
animation-duration: 2s;
animation-direction: alternate-reverse;
animation-iteration-count: 3;
}
@keyframes myanim {
0% {background-color:green; left:0px; top:0px;}
50% {background-color:maroon; left:100px; top:100px;}
100% {background-color:gray; left:0px; top:0px;}
}
</style>
</head>
<body>
<div></div>
</body>
</html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP