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

相关推荐
Jerry24 分钟前
Compose 基础知识测试
前端
changuncle33 分钟前
Angular初学者入门第三课——工厂函数(精品)
前端·javascript·angular.js
ScottePerk1 小时前
前端安全之XSS和CSRF
前端·安全·xss
PineappleCoder1 小时前
Canvas 复杂交互步骤:从事件监听 to 重新绘制全流程
前端
s3xysteak1 小时前
我要成为vue高手01:上下文
前端·javascript·vue.js
复苏季风1 小时前
前端居中布局:从 "卡壳" 到 "精通" 的全方位指南
前端·css
qb1 小时前
vue3.5.18源码:computed 在发布订阅者模式中的双重角色
前端·vue.js·架构
专注VB编程开发20年1 小时前
c# .net支持 NativeAOT 或 Trimming 的库是什么原理
前端·javascript·c#·.net
挽淚1 小时前
前端HTTP请求:Fetch api和Axios
前端
乘风丿1 小时前
🚀 从零构建 AI 代码审查机器人:让 GitLab 自动审查代码质量
前端