css动画效果之一

    <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            .box {
                width: 100px;
                height: 100px;
                background: #5CBE3E;
                animation-name: fromLeftToRight;/*   取个名字 */
                animation-duration: 4s; /*  //变化所要的时间 */
                animation-iteration-count: infinite;
                 /* 要循环多小次 */   /* (无数次循环) */
            }
            /* 定义动画 */
                      /*  用名字要和(取个名字)一样 */
            @keyframes fromLeftToRight {
                from { /*  从什么开始 */
                    margin-left: 0;
                }
                to { /* 到什么结束 */
                    margin-left: 100px;
                }
            }
        </style>
    </head>

    <body>
        <div class="box"></div>
    </body>

  

   <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            .box {
                width: 100px;
                height: 100px;
                background: #5CBE3E;
                margin: 5px;
                animation-name: fromLeftToRight;/*取个名字 */
                animation-duration: 3s;/*多小时间循环一次 */
                animation-iteration-count: infinite;
            }    /* 要循环多小次 */      /*(无限次循环) */
              .box:hover {
                animation-play-state: paused;
            }/* 当鼠标放在图片上时图片不移动 */
            
            .reverse {
                animation-direction: reverse;
            } /* 从结束到开始地点 */
            
            .alternate {
                animation-direction: alternate;
            } /*从开始到结束再从结束到开始 */
            
            .alternate-reverse {
                animation-direction: alternate-reverse;
            }/*从结束到开始再开始到结束 */
            
            @keyframes fromLeftToRight {
                from {/* 从什么开始 */
                    margin-left: 0;
                }
                to {/* 到什么结束 */
                    margin-left: 300px;
                }
            }
        </style>
    </head>

    <body>
        <div class="box"></div>
        <div class="box reverse"></div>
        <div class="box alternate"></div>
        <div class="box alternate-reverse"></div>
    </body>

  

   <head>
        <meta charset="UTF-8">
        <title></title>
        <style type="text/css">
            img {
                opacity: 0;
            }
            
            img:hover {
                animation: fadeIn 1s ease-in forwards;
            } /* hover的变化过程1秒 */
            
            @keyframes fadeIn {
                from {/* 从什么 */
                    opacity: 0;
                }
                to {/* 到什么 */
                    opacity: 1;
                }
            }
        </style>
    </head>

    <body>
        <img src="images/1.jpg" alt="一张图片

        " width="300" />
    </body>

  

转载于:https://www.cnblogs.com/qq547372511/p/5774422.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值