使用 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