css3动画(需要加前缀)

来源于技术胖的视频总结
1.动画中的关键帧@keyframes
在这里插入图片描述
demo 01

        .demo{
            width:100px;
            height:100px;
            background:palevioletred;
            position:absolute;
            /* 使用定义的动画,持续时间为2s,无限循环 */
            animation: myname 2s infinite;
        }
        /* 定义动画 myname为随意定义的动画名称*/
        @keyframes myname{
            from {top:0;left:20%}
            to {top:0;left:80%;}
        }

demo 02

        .demo{
            width:100px;
            height:100px;
            background:palevioletred;
            position:absolute;
            /* 使用定义的动画,持续时间为5s,无限循环 */
            animation: myname 5s infinite;
        }
        /* 定义动画 myname为随意定义的动画名称*/
        @keyframes myname{
            0% {top:0;left:20%;}
            25% {top:0;left:80%;background:papayawhip}
            50% {top:50%;left:80%;background:powderblue}
            75% {top:50%;left:20%;background:darkgray}
            100% {top:0;left:20%;background:beige}
        }

2.animation复合属性讲解
animation-name:动画名称
animation-duration :动画的持续时间
animation-timing-function:与transition属性相同
animation-delay:动画延迟几秒执行
anamation-iteration-count:循环的次数
animation-direction:normal(正常的)alternate(动画的饭方向播放)

3.实例Loading01
在这里插入图片描述

        .demo{
            margin:100px auto;
            width:60px;
            height:60px;
            text-align: center;
            font-size:10px;
        }
        .demo>div{
            background: pink;
            height:100%;
            width:6px;
            display: inline-block;
            animation:myname 1.2s infinite ease;
        }
        .demo>div:nth-child(2){
            animation-delay:-1.1s
        }
        .demo>div:nth-child(3){
            animation-delay:-.9s
        }
        .demo>div:nth-child(4){
            animation-delay:-.8s
        }
        .demo>div:nth-child(5){
            animation-delay:-.7s
        }
        @keyframes myname{
           0%,40%,80%{transform:scaleY(.4)}
           20%{transform: scaleY(1)}
        }

4.实例Loading02
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <script src="src/index.js"></script>
    <title>Document</title>

    <style>
        .demo{
            margin:100px auto;
            width:60px;
            height:60px;
            position:relative;
        }
        .demo>div{
            width:100%;
            height:100%;
            border-radius:50%;
            background:blueviolet;
            opacity:0.6;
            position:absolute;
            top:0px;
            left:0px;
            animation:myname 2s infinite ease;
        }
        .demo>div:nth-child(2){
            animation-delay:-1s
        }
        @keyframes myname{
           0%,100%{transform:scale(0.0)}
           50%{transform: scale(1)}
        }
    </style>
  </head>
  <body>
    <div class="demo">
       <div></div>
       <div></div>
    </div>
  </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值