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

相关推荐
华玥作者37 分钟前
[特殊字符] VitePress 对接 Algolia AI 问答(DocSearch + AI Search)完整实战(下)
前端·人工智能·ai
Mr Xu_1 小时前
告别冗长 switch-case:Vue 项目中基于映射表的优雅路由数据匹配方案
前端·javascript·vue.js
前端摸鱼匠1 小时前
Vue 3 的toRefs保持响应性:讲解toRefs在解构响应式对象时的作用
前端·javascript·vue.js·前端框架·ecmascript
lang201509281 小时前
JSR-340 :高性能Web开发新标准
java·前端·servlet
好家伙VCC2 小时前
### WebRTC技术:实时通信的革新与实现####webRTC(Web Real-TimeComm
java·前端·python·webrtc
未来之窗软件服务3 小时前
未来之窗昭和仙君(六十五)Vue与跨地区多部门开发—东方仙盟练气
前端·javascript·vue.js·仙盟创梦ide·东方仙盟·昭和仙君
嘿起屁儿整3 小时前
面试点(网络层面)
前端·网络
VT.馒头3 小时前
【力扣】2721. 并行执行异步函数
前端·javascript·算法·leetcode·typescript
phltxy4 小时前
Vue 核心特性实战指南:指令、样式绑定、计算属性与侦听器
前端·javascript·vue.js
Byron07075 小时前
Vue 中使用 Tiptap 富文本编辑器的完整指南
前端·javascript·vue.js