3D旋转tab图

上图

代码

html 复制代码
<!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>
相关推荐
前端大卫1 小时前
你所不知道的 9个CSS 小知识!
前端·css
前端Hardy1 小时前
HTML&CSS:卡片式提交框
css·html
前端Hardy1 小时前
HTML&CSS:超有趣的登录表单
javascript·css·html
背书包的甜瓜1 小时前
使用sass 实现px转vh或vw,适配适老化时,在设计图字体大小的基础上,增加3px(可配置),
前端·css·sass
我是谁谁2 小时前
Canvas 高级应用与实战项目<3>
javascript·css·canvas
江城开朗的豌豆2 小时前
CSS篇:CSS动画实战:如何让一个盒子平滑移动到另一个盒子?
前端·css·面试
harry7592 小时前
Flex-1 布局实现内部滚动条
前端·javascript·css
the_one2 小时前
🚀让动画动起来!用 CSS 延迟变量打造交互式炫酷小球动画
前端·javascript·css
_Le_2 小时前
css 小师系列:为什么 background 渐变可以叠加,而颜色不可以?
前端·css
前端菜鸟日常3 小时前
前端性能优化核弹级方案:CSS分层渲染+Wasm,首屏提速300%!
前端·css·性能优化·wasm