【3D旋转动画小猪佩奇】

运行结果:

代码:

<!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">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        
        ul {
            width: 200px;
            margin: 100px auto;
        }
        
        li {
            float: left;
            list-style: none;
            width: 200px;
            height: 200px;
            perspective: 400px;
            margin: 0 10px;
        }
        /*疯狂星期四*/
        
        @keyframes fz {
            0% {
                transform: rotate3d(0, 0, 0, 0deg);
            }
            /* X轴 */
            25% {
                transform: rotate3d(1, 0, 0, 90deg);
            }
            /* Y轴 */
            50% {
                transform: rotate3d(0, 1, 0, 180deg);
            }
            /* z轴 */
            75% {
                transform: rotate3d(0, 0, 1, 270deg);
            }
            /* 对角轴 */
            100% {
                transform: rotate3d(1, 1, 0, 360deg);
            }
        }
        /*魔方猪*/
        
        @keyframes fz1 {
            to {
                transform: rotate3d(1, 1, 1, 360deg);
            }
        }
        /*对角冲锋猪*/
        
        @keyframes fz2 {
            to {
                transform: rotate3d(1, 1, 0, 360deg)rotate3d(0, 1, 1, 360deg);
            }
        }
        
        .box {
            position: relative;
            width: 100%;
            height: 100%;
            transform-style: preserve-3d;
            transition: all 5s;
            animation: fz2 2s infinite linear;
        }
        
        ul>li>.box:active {
            animation: fz1 2s infinite linear;
        }
        
        .box:hover {
            animation: fz 2s infinite linear;
        }
        
        .front,
        .bottom,
        .top,
        .back,
        .left,
        .right {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            color: #fff;
            text-align: center;
            line-height: 35px;
        }
        
        .front {
            background: url(../img/1.jpeg)no-repeat center;
            z-index: 1;
            transform: translateZ(100px);
        }
        
        .bottom {
            background: url(../img/2.jpeg)no-repeat center;
            transform: translateY(100px) rotateX(-90deg);
        }
        
        .top {
            background: url(../img/3.jpeg)no-repeat center;
            transform: translateY(-100px) rotateX(90deg);
        }
        
        .back {
            background: url(../img/4.jpeg)no-repeat center;
            transform: translate3d(0px, 0px, -100px)rotateX(180deg);
        }
        
        .left {
            background: url(../img/5.jpeg)no-repeat center;
            transform: translateX(100px) rotateY(90deg);
        }
        
        .right {
            background: url(../img/6.jpeg)no-repeat center;
            transform: translateX(-100px) rotateY(-90deg);
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <div class="box">
                <div class="front"></div>
                <div class="bottom"></div>
                <div class="top"></div>
                <div class="back"></div>
                <div class="left"></div>
                <div class="right"></div>
            </div>
        </li>
    </ul>
</body>

</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值