前端【动画】练习

动画

定义关键帧对话   @keyframes{}

轮播图

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>轮播图</title>
    <style>
        /* 1.首尾不衔接
        2.图片没有停留间隙 */
        @keyframes move {
           0%{left: 0;}
           /* 24%{left: 0;} */
           25%{left:-400px;}
           50%{left: -800px;}
           75%{ left: -1200px;}
           100%{ left: -1600px;}
        }
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .window{
            width: 400px;
            height: 300px;
            overflow: hidden;
            position: relative;
            box-shadow: 2px 2px 5px gray;
            margin: 0 auto;
        }
        .move{
            width: 2000px;
            height: 300px;
            position: absolute;
            animation: move 8s 
                      linear infinite;
        }
        li{
            width: 400px;
            height: 300px;
            float: left;
        }
        li img{
            display: block;
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <div class="window">
        <ul class="move">
            <li><img src="img/xhr1.jpeg" alt=""></li>
            <li><img src="img/xhr2.jpeg" alt=""></li>
            <li><img src="img/xhr3.jpeg" alt=""></li>
            <li><img src="img/xhr4.jpeg" alt=""></li>
        </ul>
    </div>
</body>
</html>

模仿华为充电

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模仿华为充电效果</title>
    <style>
        /* :root{
            --my--color
        } */
        @keyframes roll{
            0%{
                transform: rotate(0);
                border-radius:  32% 48% 36% 46%;
            }
            50%{
                transform: rotate(300deg);
                border-radius: 42% 44% 36% 40%;
            }
            100%{
                transform: rotate(360deg);
                border-radius:  32% 48% 36% 46%;
            }
        }
        @keyframes li-move{
            from{transform: translateY(0);}
            to{transform: translateY(-200px);}
        }
        @keyframes change-color{
            from{
                filter: contrast(10);
                /* hue-rotate(0); */
            }
            to{
                filter: contrast(10)
                hue-rotate(360deg);
            }
        }
        *{
            margin: 0;
            padding: 0;
            list-style: none;
            box-sizing: border-box;
        }
        .wrap{
           height: 100vh;
           background-color: #000;
           overflow: hidden;
           filter: contrast(10) hue-rotate(0);
           animation:change-color 4s linear infinite ;
        }
        .circle{

            width: 200px;
            height: 200px;
            background-color: tomato;
            margin: 50px auto;
            border-radius: 32% 48% 36% 46%;
            filter: blur(8px);
            animation: roll 4s linear infinite;
        }
        .circle div{
            width: 184px;
            height: 184px;
            margin: 8px;
            background-color: #000;
            border-radius: 50%;
          
    
        }
        ul{
            filter: blur(5px);
            width: 100px;
            height: 30px;
            background-color: tomato;
            margin: 180px auto;
            border-radius: 30px 30px 0 0;
            position: relative;
        }
        ul li{
            border-radius: 50%;
            background-color: tomato;
            position: absolute;
            animation:li-move  2s linear infinite;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="circle">
            <div></div>
        </div>
        <ul>
            <li style="width:15px;height:15px;left:5px;top: 0;animation-duration:2s;"></li>
            <li style="width:20px;height:20px;left:12px;top: 0;animation-duration:2.5s;"></li>
            <li style="width:35px;height:35px;left:57px;top: 0;animation-duration:3.5s;"></li>
            <li style="width:26px;height:26px;left: 58px;top: 0;animation-duration:1.5s;"></li>
            <li style="width:30px;height:30px;left:45px ;top: 0;animation-duration:1s;"></li>
            <li style="width:18px;height:18px;left:68px ;top: 0;animation-duration:1.8s;"></li>
            <!-- <li style="width:15px;height:15px;left:68px ;top: 0;"></li>
            <li style="width:15px;height:15px;left: 58px;top: 0;"></li> -->
        </ul>
    </div>
</body>
</html>

旋转的立方体

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>旋转的立方体</title>
    <style>
        @keyframes roll{
            from{
                transform: rotateX(0) rotateY(0) rotateZ(0);
            }
            to{
                transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg);
            }
        }
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        body{
            padding: 100px;

        }
        ul{
            width: 200px;
            height: 200px;
            position: relative;
            /* 开启3D效果 */
            transform-style: preserve-3d;
            animation: roll 4s linear infinite ;
        }
        li{
            width: 200px;
            height: 200px;
            position: absolute;
            opacity:.5 ;
        }
        /* 1,2上下
        3,4左右
        5,6前后 */
        li:nth-of-type(1){
            background-image:url() ;
            background-color: gold;
            transform: rotateX(90deg)
                      translateZ(100px);
        }
        li:nth-of-type(2){
            background-color: tomato;
            transform: rotateX(-90deg)
                      translateZ(100px);
        }
        li:nth-of-type(3){
            background-color: pink;
            transform: rotateY(90deg)
                      translateZ(100px);
        }
        li:nth-of-type(4){
            background-color: yellowgreen;
            transform: rotateY(-90deg)
                      translateZ(100px);
        }
        li:nth-of-type(5){
            background-color: skyblue;
            transform: 
                      translateZ(100px);
        }
        li:nth-of-type(6){
            background-color: orange;
            transform: rotateY(180deg)
                      translateZ(100px);
        }
        .small{
            width: 100px;
            height: 100px;
            margin: 50px;
        }
          li:nth-of-type(7){
            background-color: gold;
            transform: rotateX(90deg)
                      translateZ(50px);
        }
        li:nth-of-type(8){
            background-color: tomato;
            transform: rotateX(-90deg)
                      translateZ(50px);
        }
        li:nth-of-type(9){
            background-color: pink;
            transform: rotateY(90deg)
                      translateZ(50px);
        }
        li:nth-of-type(10){
            background-color: yellowgreen;
            transform: rotateY(-90deg)
                      translateZ(50px);
        }
        li:nth-of-type(11){
            background-color: skyblue;
            transform: translateZ(50px);
        }
        li:nth-of-type(12){
            background-color: orange;
            transform: rotateY(180deg)
                      translateZ(50px);
        }
    </style>
</head>
<body>
    <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>

        <li class="small"></li>
        <li class="small"></li>
        <li class="small"></li>
        <li class="small"></li>
        <li class="small"></li>
        <li class="small"></li> 
    </ul>
</body>
</html>

loading

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>loading</title>
    <style>
        @keyframes roll{
            from{
                transform: rotate(0);
                filter: hue-rotate(0);
            }
            to{
                transform: rotate(360deg);
                filter: hue-rotate(360deg);
            }
        }
        *{
            margin: 0;
            padding: 0;
        }
        .wrap{
            width: 100vw;
            height:100vh ;
            background-color: #222;
            overflow: hidden;
        }
        .d1{
            width: 200px;
            height: 200px;
            margin: 100px  auto;
            background-image: -webkit-linear-gradient(45deg,transparent 40%,yellowgreen 60%);
            background-image: linear-gradient(45deg,transparent 40%,yellowgreen 60%);
            border-radius: 50%;
            position: relative;
            overflow: hidden;
            animation: roll 2s linear infinite ;
        }
        .mask{
            width: 192px;
            height: 192px;
            background-color: #000;
            position: absolute;
            left: 0;
            bottom: 0;
            border-radius: 50%;
            filter: blur(8px);

        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="d1">
            <div class="mask"></div>
        </div>
    </div>
</body>
</html>

loading效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>loading效果</title>
    <style>
        @keyframes clock{
            from{transform: rotate(0);}
                to{transform: rotate(360deg);}
            }
            @keyframes rect1{
                from{margin-top: 92px;opacity: 0;}
                to{margin-top: 0;opacity: 1;}
            }
            @keyframes rect2 {
                0% { left: 20px;top: 20px;}
                25% { left: 170px;top: 20px;}
                50% { left: 170px;top: 170px;}
                75% { left: 20px;top: 170px;}
                100% { left: 20px;top: 20px;}
            }
        *{
            margin: 0;
            padding: 0;
            list-style: none;
            box-sizing: border-box;
        }
        .item{
            width: 200px;
            height: 200px;
            background-color: #594889;
            margin: 10px;
            position: relative;
            overflow: hidden;
        }
        .clock{
            width: 160px;
            height: 160px;
            border: 5px solid white;
            border-radius: 50%;
            position: absolute;
            left: 20px;
            top: 20px;
        }
        .zhen1{
            width: 4px;
            height: 70px;
            background-color: white;
            position: absolute;
            left: 98px;
            top: 30px;
            transform-origin: center bottom;
            animation: clock 2s linear infinite;
        }
        .zhen2{
            width: 4px;
            height: 50px;
            background-color: white;
            position: absolute;
            left: 98px;
            top: 50px;
            transform-origin: center bottom;
            animation: clock 6s linear infinite;
        }
        .rect{
            width: 100px;
            height: 100px;
            border: 4px solid white;
            margin: 50px;
            overflow: hidden;
        }
         .rect div{
            width: 100%;
            height: 100%;
            background-color: white;
            margin-top: 92px;
            opacity: 0;
            animation: rect1 4s linear infinite;
        }
        .item .slider{
            width: 10px;
            height: 10px;
            background-color: white;
            position: absolute;
            left: 20px;
            top: 20px;
            animation: rect2 4s linear infinite;

        }
    </style>
</head>
<body>
     <div class="item">
        <div class="clock"></div>
        <div class="zhen1"></div>
        <div class="zhen2"></div>
     </div>
     <div class="item">
        <div class="rect">
            <div></div>
        </div>
       
        <div class="slider"></div>
     </div>
    
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值