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

相关推荐
2601_949857431 分钟前
Flutter for OpenHarmony Web开发助手App实战:CSS参考
前端·css·flutter
无法长大2 分钟前
如何判断项目需不需要用、能不能用Tailwind CSS
前端·css·vue.js·elementui·vue3·tailwind css
橙露4 分钟前
移动端前端适配:Rem、VW/VH 与媒体查询的综合应用指南
前端·媒体
GGGG寄了19 分钟前
CSS——CSS引入方式+选择器类型
前端·css·html
墨染青竹梦悠然20 分钟前
基于Django+vue的图书借阅管理系统
前端·vue.js·后端·python·django·毕业设计·毕设
码农六六24 分钟前
js函数柯里化
开发语言·前端·javascript
爱敲代码的小鱼29 分钟前
Vue的简介:
前端·javascript·vue.js
H_ZMY1 小时前
前端瀑布流布局:从基础实现到高性能优化全解析
前端·性能优化
星夜落月1 小时前
从零部署Wallos:打造专属预算管理平台
服务器·前端·网络·建站