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

更新时间: 2020-06-24

1K+ 浏览

开始你的 职业生涯

完成课程,获取认证

开始学习
广告
© . All rights reserved.