lable与input连用特殊动作效果

html 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /*label 可以扩大触点  label中有一个for属性需要与id连用  */
        
        * {
            padding: 0;
            margin: 0;
        }
        
        input {
            display: none;
        }
        
        .container {
            height: 300px;
            width: 520px;
            display: flex;
            justify-content: space-between;
            margin: 150px auto;
            text-transform: uppercase;
            perspective: 1000px;
        }
        
        .label {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        
        .label label {
            width: 100px;
            height: 90px;
            text-align: center;
            line-height: 90px;
        }
        
        .label label:hover {
            opacity: 0.8;
        }
        
        .label label:nth-child(1) {
            background: rebeccapurple;
        }
        
        .label label:nth-child(2) {
            background: yellowgreen;
        }
        
        .label label:nth-child(3) {
            background: palegreen;
        }
        
        .container .table_body {
            width: 400px;
            height: 300px;
            transform-style: preserve-3d;
            transform: rotateX(0deg);
            transition: all 1s ease;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
        }
        
        .container .table_body .table_content {
            position: absolute;
            width: 350px;
            height: 260px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            text-align: center;
            color: #fff;
        }
        
        .container .table_body .table_content:nth-child(1) {
            background: rebeccapurple;
            transform: translateY(-130px) rotateX(90deg);
        }
        
        .container .table_body .table_content:nth-child(2) {
            background: yellowgreen;
            transform: translateZ(130px);
        }
        
        .container .table_body .table_content:nth-child(3) {
            background: palegreen;
            transform: translateY(130px) rotateX(-90deg);
        }
        
        #top:checked~.table_body {
            transform: rotateX(-90deg);
        }
        
        #middle:checked~.table_body {
            transform: rotateX(0deg);
        }
        
        #bottom:checked~.table_body {
            transform: rotateX(90deg);
        }
    </style>
</head>

<body>
    <div class="container">
        <input type="radio" name="tab" id="top">
        <input type="radio" name="tab" id="middle">
        <input type="radio" name="tab" id="bottom">
        <div class="table_body">
            <div class="table_content">
                <h3>top</h3>
            </div>
            <div class="table_content">
                <h3>middle</h3>
            </div>
            <div class="table_content">
                <h3>bottom</h3>
            </div>
        </div>
        <div class="label">
            <label for="top">top</label>
            <label for="middle">middle</label>
            <label for="bottom">bottom</label>
        </div>
    </div>
</body>

</html>

lable与input连用特殊动作效果

相关推荐
逆袭的小黄鸭5 分钟前
掌握 JavaScript:理解原型和原型链
前端·javascript·面试
患得患失9495 分钟前
【前端】【tailwind】tailwind默认重置了样式
前端·tailwind
SparkleTiger6 分钟前
2025好运-浏览器篇-回流与重绘
前端
前端小趴菜057 分钟前
记录 vue-router访问 / 路径直接重定向到有权限的第一个菜单
前端·javascript·vue.js
the_one8 分钟前
超燃!手把手教你打造赛博朋克风流光按钮🤩🤩🤩
前端·css
SparkleTiger8 分钟前
2025好运-CSS篇-BFC
前端
蜗牛快跑1239 分钟前
最受欢迎的十个 JavaScript 动画库 -2025
前端
疏狂难除11 分钟前
【Tauri2】013——前端Window Event与创建Window
前端·javascript·rust·react·tauri2
yanyu-yaya35 分钟前
@progress/kendo-react-dropdowns <ComboBox>组件报错,解决
前端·javascript·react.js
小破孩呦40 分钟前
动态循环表单+动态判断表单类型+动态判断表单是否必填方法
前端·javascript·html