代码
提交代码
<!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> @keyframes go{ from{ width:200px; } to{ width:500px } } .demo{ width:100px; height:100px; background: #000; animation:go 2s ease-in 2s ;/*动画反向播放*/ } .demo-1{ width:100px; height:100px; background: #000; animation:go 2s ease-in 2s forwards; } .demo-2{ width:100px; height:100px; background: #000; animation:go 2s ease-in 2s backwards; } </style> </head> <body> <h2>正常动画</h2> <div class="demo"></div> <h2>设置 forwards</h2> <div class="demo-1"></div> <h2>设置 backwards 注意观察开始</h2> <div class="demo-2"></div> </body> </html>
运行结果