使用 CSS 设置带有缓慢开始和结束的动画


使用具有ease-in-out值的 animation-timing-function 属性,以使用 CSS 设置动画,使其以缓慢开始和结束的速度运行

示例

实时演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            position: relative;
            background-color: #808000;
            animation-name: myanim;
            animation-duration: 2s;
            animation-direction: alternate-reverse;
            animation-iteration-count: 3;
         }
         @keyframes myanim {
            from {left: 100px;}
            to {left: 200px;}
         }
         #demo {animation-timing-function: ease-out;}
      </style>
   </head>
   <body>
      <div id = "demo">ease-in-out effect</div>
   </body>
</html>

更新于: 2020 年 6 月 24 日

269 次浏览

开启你的职业生涯职业生涯

通过完成课程获得认证

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