3D旋转tab图

上图

代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3D旋转tab图</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            height: 100vh;
            background: linear-gradient(to top, #29323c, #485563);
        }

        .container {
            width: 500px;
            display: flex;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-45%, -50%);
            color: #ffffff;
            text-transform: uppercase;
            perspective: 1300px;
        }

        input {
            display: none;
        }

        .labels {
            height: 250px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .tab {
            width: 100px;
            height: 80px;
            line-height: 80px;
            text-align: center;
            cursor: pointer;
        }

        .tab:nth-child(1) {
            background-color: #00b4db;
        }

        .tab:nth-child(2) {
            background-color: #009bc5;
        }

        .tab:nth-child(3) {
            background-color: #007ba4;
        }

        .content {
            width: 95%;
            height: 230px;
            position: absolute;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            background-color: red;
        }

        .content h1 {
            font-size: 28px;
        }

        .content p {
            font-size: 14px;
        }

        .content:nth-child(1) {
            background-color: #00b4db;
            transform: rotateX(-270deg) translateY(-115px);
            transform-origin: top center;
        }

        .content:nth-child(2) {
            background-color: #009bc5;
            transform: translateZ(115px);
        }

        .content:nth-child(3) {
            background-color: #007ba4;
            transform: rotateX(-90deg) translateY(115px);
            transform-origin: bottom center;
        }

        .cube {
            position: relative;
            flex: 1;
            transform-style: preserve-3d;
            transition: transform 0.5s ease-in;
        }

        #top:checked ~ .cube {
            transform: rotateX(-90deg);
        }

        #middle:checked ~ .cube {
            transform: rotateX(0deg) translateY(10px);
        }

        #bottom:checked ~ .cube {
            transform: rotateX(90deg);
        }
    </style>
</head>
<body>
<div class="container">
    <input type="radio" name="tabs" id="top" checked/>
    <input type="radio" name="tabs" id="middle"/>
    <input type="radio" name="tabs" id="bottom"/>
    <div class="cube">
        <div class="content">
            <h1>top content</h1>
            <p>this is top content</p>
        </div>
        <div class="content">
            <h1>middle content</h1>
            <p>this is middle content</p>
        </div>
        <div class="content">
            <h1>bottom content</h1>
            <p>this is bottom content</p>
        </div>
    </div>
    <div class="labels">
        <label for="top" class="tab">top</label>
        <label for="middle" class="tab">middle</label>
        <label for="bottom" class="tab">bottom</label>
    </div>
</div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

马卫斌 前端工程师

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

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

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

打赏作者

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

抵扣说明:

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

余额充值