所属分类:web前端开发
使用animation-direction属性来设置动画是向前播放、向后播放还是交替循环播放:
实时演示
<!DOCTYPE html> <html> <head> <style> div { width: 150px; height: 200px; background-color: yellow; animation-name: myanim; animation-duration: 2s; animation-direction: reverse; } @keyframes myanim { from { background-color: green; } to { background-color: blue; } } </style> </head> <body> <div></div> </body> </html>