设置动画未播放时的元素 CSS 样式


使用 animation-fill-mode 属性为动画未播放时的元素设置样式

示例

实时演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            position: relative;
            background: red;
            animation-name: myanim;
            animation-duration: 2s;
            animation-fill-mode: backwards;
         }
         @keyframes myanim {
            from {left: 0px; background-color: green;}
            to {left: 200px; background-color: blue;}
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>

更新时间:2020 年 6 月 24 日

85 次浏览

开启你的职业生涯

完成课程即可获得认证

开始
广告
© . All rights reserved.