【无标题】

HTML5+CSS3 3D旋转案例

HTML5+CSS3 3D旋转案例

案例1

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>Document</title>
        <style>
            .box {
                perspective: 500px;

                position: relative;
                margin: 100px auto;
                width: 200px;
                height: 300px;
                transition: all 1s;
                transform-style: preserve-3d;
            }

            .box:hover {
                transform: rotateY(60deg);
            }

            .box div {
                position: absolute;
                top: 0px;
                left: 0px;
                width: 100%;
                height: 100%;

                background-color: orange;
            }

            .box div:last-child {
                background-color: purple;
                transform: rotateX(60deg);
            }
        </style>
    </head>
    <body>
        <div class="box">
            <div></div>
            <div></div>
        </div>
    </body>
</html>

效果:
在这里插入图片描述

案例2

3D旋转立方体
在这里插入图片描述

```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>Document</title>
        <style>
            ul {
                margin: 100px auto;
                list-style: none;
            }
            ul li {
                float: left;
                perspective: 300px;
                margin: 10px;
            }

            .box {
                position: relative;
                width: 100px;
                height: 40px;
                transition: all 0.4s linear;
                transform-style: preserve-3d;
            }

            .box:hover {
                transform: rotateX(90deg);
            }

            .front,
            .bottom {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                line-height: 40px;
                text-align: center;
                font-size: 20px;
                color: #fff;
            }

            .front {
                background-color: orange;
                transform: translateZ(20px);
            }

            .bottom {
                background-color: purple;
                transform: translateY(20px) rotateX(-90deg);
            }
        </style>
    </head>
    <body>
        <ul>
            <li>
                <div class="box">
                    <div class="front">前面</div>
                    <div class="bottom">下面</div>
                </div>
            </li>
            <li>
                <div class="box">
                    <div class="front">前面</div>
                    <div class="bottom">下面</div>
                </div>
            </li>
            <li>
                <div class="box">
                    <div class="front">前面</div>
                    <div class="bottom">下面</div>
                </div>
            </li>
            <li>
                <div class="box">
                    <div class="front">前面</div>
                    <div class="bottom">下面</div>
                </div>
            </li>
        </ul>
    </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值