CSS动画之Animation

一、Animation 常用属性

  1. @keyframes 装饰器

  2. animation-name 动画名称 string

  3. animation-duration 动画完成一次所需时间 time

  4. animation-timing-function 动画曲线 linear ~ ease ~ ease-in ~ ease-out ~ ease-in-out ~ cubic-bezier(n,n,n,n)

  5. animation-delay 延迟时间 time

  6. animation-iteration-count 动画播放次数 n/infinite

  7. animation-direction 规定动画在下一周期逆向播放 normal/alternate

  8. animation-play-state 暂停或播放动画 paused/running //js中控制该属性

  9. animation-fill-mode 规定动画时间之外的状态 none 默认动画结束后回归最初状态/ forwards(动画结束后应用最末状态) / backwards动画开始前应用最初状态 / both 两者都兼用

简写:

  1. animation: animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction;

  2. animation: animation-name animation-duration animation-delay animation-timing-function animation-iteration-count animation-direction, animation-name2 支持多动画; //delay 可省略

eg: 动态弹框

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        ul,li{
            list-style: none;
        }
        @keyframes myMode {
             0% {
                top: -100%;
              }
              25% {
                top: 60%;
              }
              50% {
                top: 48%;
              }
              75% {
                top: 52%;
              }
              100%{
                top: 50%;
              }
        }
        .box{
            width: 200px;
            height: 200px;
            position: absolute;
            left: 45%;
            background: red;
            animation: myMode 2s 1s cubic-bezier(0.25, 0.85, 1, 1) 1 forwards; 
        }
    </style>
</head>
<body>
   <div class="box">我是弹框</div>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容