HTML5基础加强css样式篇(animation简写,控制多个动画,动画帧简写)(三十二)

1.animation简写例子:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        .box {
            /* .box 默认样式 */
            margin: 200px 0 0 200px;
            width: 200px;
            height: 200px;
            background-color: orange;
                     /* 动画的名字,播放时间,延时时间,动画效果,播放次数,播放顺序*/
            animation: anim2 3s 2s linear infinite alternate;

        }
        /*当鼠标悬浮在.box时,暂停播放动画*/
        .box:hover {
            animation-play-state: paused;
        }

        @keyframes anim2 {
            0%{ 
                background: url("img/1.png") no-repeat;
                background-size: 100%;
            }
            50%{
                background: url("img/2.png") no-repeat;
                background-size: 100%;
            }
            100%{
                background: url("img/3.png") no-repeat;
                background-size: 100%;
            }
        }



    </style>
</head>
<body>

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

<script type="text/javascript">
</script>
</body>
</html>

2.动画应用:

   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        .box-3d{

            width: 200px;
            height: 200px;
            /*开启3D*/
            transform-style: preserve-3d;

            margin: 200px auto;

            position: relative;

            /*设置3D盒子的变换中心点*/
            transform-origin: center center -100px;

            /*transform: rotateX(15deg) rotateY(15deg);*/

            animation: anim1 10s linear infinite alternate;

        }

        @keyframes anim1 {
            0%{
                transform: rotateX(0deg) rotateY(0deg);
            }

            100%{
                transform: rotateX(360deg) rotateY(360deg);
            }
        }



        .box{
            width: 200px;
            height: 200px;
            text-align: center;
            line-height: 200px;
            font-size: 36px;

            position: absolute;
        }
        .box1{  background-color: rgba(0, 0, 0, .2); top: -200px;
            transform-origin: bottom;
            transform: rotateX(90deg)}
        .box2{  background-color: rgba(255, 0, 0, .2); left: 200px;
            transform-origin: left;
            transform: rotateY(90deg)
        }
        .box3{  background-color: rgba(0, 255, 0, .2); top: 200px;
            transform-origin: top;
            transform: rotateX(-90deg)

        }
        .box4{  background-color: rgba(0, 0, 255, .2); left: -200px;
            transform-origin: right;
            transform: rotateY(-90deg)
        }
        .box5{  background-color: rgba(255, 255, 0, .2);
            transform: translateZ(-200px)
        }
        .box6{  background-color: rgba(0, 255, 255, .2);}

    </style>
</head>
<body>

<div class="box-3d" id="box3d">
    <div class="box box1">1</div>
    <div class="box box2">2</div>
    <div class="box box3">3</div>
    <div class="box box4">4</div>
    <div class="box box5">5</div>
    <div class="box box6">6</div>
</div>


</body>
</html>

3,控制多个动画:已,分割即可

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        .box {
            /* .box 默认样式 */
            margin: 200px 0 0 200px;
            width: 200px;
            height: 200px;
            background-color: orange;

            animation: anim2 3s 2s linear infinite alternate, anim3 3s;

        }
        /*当鼠标悬浮在.box时,暂停播放动画*/
        .box:hover {
            animation-play-state: paused;
        }

        @keyframes anim2 {
            0%{
                background: url("img/1.png") no-repeat;
                background-size: 100%;
            }
            50%{
                background: url("img/2.png") no-repeat;
                background-size: 100%;
            }
            100%{
                background: url("img/3.png") no-repeat;
                background-size: 100%;
            }
        }

        @keyframes anim3 {
            10%{
                border: 10px solid red;
            }
            50%{
                border: 50px solid blue;
            }
        }



    </style>
</head>
<body>

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

<script type="text/javascript">
</script>
</body>
</html>


4.动画帧简写:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        .box {
            /* .box 默认样式 */
            margin: 200px 0 0 200px;
            width: 200px;
            height: 200px;
            background-color: orange;

            animation: anim2 3s linear infinite alternate;

        }
        /*当鼠标悬浮在.box时,暂停播放动画*/
        .box:hover {
            animation-play-state: paused;
        }

        @keyframes anim2 {
            /*使用,设置各帧的相同样式 0%{} 和 90{} 使用相同样式*/
            0%, 90%{
                background: url("img/1.png") no-repeat;
                background-size: 100%;
            }
            50%{
                background: url("img/2.png") no-repeat;
                background-size: 100%;
            }
            100%{
                background: url("img/3.png") no-repeat;
                background-size: 100%;
            }
        }





    </style>
</head>
<body>

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

<script type="text/javascript">
</script>
</body>
</html>





  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

咸鸭蛋炒饭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值