day 9 动画特效(animation)

@keyframes关键帧

动画就是从一个css样式变换到另一个css 样式,我们通过@keyframes来定义每一个状态,用百分比来规定改变发生的时间,也可以使用from{},to{}.

动画

animation-name动画属性名
animation-duration动画持续时间
animation-delay动画延迟时间
animation-timing-function动画速度曲线(ease慢快慢这是默认值,linear匀速)
animation-iteration-count定义循环次数(infinite为无限循环)
animation-direction:alternate动画轮流反向播放
animation-play-tate动画状态
animation-fill-mode:forwards保留最后一帧动画

案例 :实现3d旋转

<!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>case03</title>
    <style>
        @keyframes roll{
            from{
                transform: rotateX(0) rotateY(0) rotateZ(0);
            }
            to{
                transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg);
            }
        }
        *{
            margin: 0;
            padding: 0;
        }
        div{
            width: 200px;
            height: 200px;
            position: absolute;
            background-image: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fci.xiaohongshu.com%2F16c008be-7b7a-a3e4-1e4a-02cae01ebce7%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fci.xiaohongshu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1653652026&t=c5e36431e7f35c016069b8e575dcbbcb);
            background-size: 200px 200px;
            background-repeat: no-repeat;
        }
        .wrap{
            margin: 100px;
            animation: roll 20s linear infinite;
            transform-style: preserve-3d;
        }
        /* 左右 */
        .wrap div:nth-of-type(1){
            transform: rotateY(-90deg) translateZ(100px);
            /* background-color: aquamarine; */
        }
        .wrap div:nth-of-type(2){
            transform: rotateY(90deg) translateZ(100px);
            /* background-color: deepskyblue; */
        }
        /* 上下 */
        .wrap div:nth-of-type(3){
            transform: rotateX(90deg) translateZ(100px);
            /* background-color: gold; */
        }
        .wrap div:nth-of-type(4){
            transform: rotateX(-90deg) translateZ(100px);
            /* background-color: yellow; */
        }
        /* 前后 */
        .wrap div:nth-of-type(5){
            transform:  translateZ(100px);
            /* background-color: purple; */
        }
        .wrap div:nth-of-type(6){
            transform: rotateX(180deg) translateZ(100px);
            /* background-color: green; */
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值