使用 CSS 为动画设置一个缓慢开始、然后快速进行、最后缓慢结束的步骤
使用 animation-timing-function 属性,使用 ease 值来通过 CSS 为动画设置一个缓慢开始、然后快速进行、最后缓慢结束的步骤
示例
<!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 { from {left: 100px;} to {left: 200px;} } #demo1 {animation-timing-function: ease;} </style> </head> <body> <div id = "demo1">ease effect</div> </body> </html>
广告