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连用特殊动作效果

相关推荐
LuciferHuang4 小时前
震惊!三万star开源项目竟有致命Bug?
前端·javascript·debug
GISer_Jing4 小时前
前端实习总结——案例与大纲
前端·javascript
天天进步20154 小时前
前端工程化:Webpack从入门到精通
前端·webpack·node.js
姑苏洛言5 小时前
编写产品需求文档:黄历日历小程序
前端·javascript·后端
知识分享小能手6 小时前
Vue3 学习教程,从入门到精通,使用 VSCode 开发 Vue3 的详细指南(3)
前端·javascript·vue.js·学习·前端框架·vue·vue3
姑苏洛言6 小时前
搭建一款结合传统黄历功能的日历小程序
前端·javascript·后端
你的人类朋友7 小时前
🤔什么时候用BFF架构?
前端·javascript·后端
知识分享小能手7 小时前
Bootstrap 5学习教程,从入门到精通,Bootstrap 5 表单验证语法知识点及案例代码(34)
前端·javascript·学习·typescript·bootstrap·html·css3
一只小灿灿8 小时前
前端计算机视觉:使用 OpenCV.js 在浏览器中实现图像处理
前端·opencv·计算机视觉