zoukankan      html  css  js  c++  java
  • 选项卡

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>选项卡</title>
    <script src="./jquery-1.8.3.js"></script>
    <style>
    *{margin:0;padding:0;list-style: none}
    .wrap{
    300px;
    height:400px;
    border:1px solid red;
    margin:0 auto;
    }
    .title{
    height:50px;
    }
    .title li{
    100px;
    height:50px;
    border:1px solid red;
    float:left;
    box-sizing:border-box;
    border-top:none;
    border-left:none;
    text-align:center;
    line-height: 50px;
    }
    /*last-child 选择器匹配属于其父元素的最后一个子元素的每个元素。*/
    .title li:last-child{
    border-right:none;
    }
    .title .item{
    border-bottom:none;
    }

    .content li{
    100%;
    height:350px;
    /*border:1px solid green;*/
    text-align:center;
    line-height:350px;
    display:none;
    }
    .content .active{
    display:block;
    }
    </style>
    </head>
    <body>
    <div class="wrap">
    <ul class="title">
    <li class="item">标题一</li>
    <li >标题二</li>
    <li >标题三</li>
    </ul>
    <ul class="content">
    <li class="active">内容一</li>
    <li>内容二</li>
    <li>内容三</li>
    </ul>
    </div>
    <script>
    // 给标题添加绑定事件
    $('.title li').click(function(){
    // siblings() 获得匹配集合中每个元素的同胞,通过选择器进行筛选是可选的
    $(this).addClass('item').siblings().removeClass('item');
    // 获取索引值 通过索引值将标题和内容 关联起来
    var index=$(this).index();
    $('.content li').eq(index).addClass('active');
    $('.content li').eq(index).siblings().removeClass('active');
    })
    </script>

    </body>
    </html>

  • 相关阅读:
    POJ
    UPC-5843: 摘樱桃(最优状态递推)
    BZOJ-1088 [SCOI2005]扫雷Mine(递推+思维)
    HDU-3065 病毒侵袭持续中(AC自动机)
    BZOJ-4236 JOIOJI (map查找+思维)
    HDU-2896 病毒侵袭(AC自动机)
    Hrbust-2060 截取方案数(KMP)
    UVALive 4490 压缩DP
    UVALive 5881
    UVALive 4168
  • 原文地址:https://www.cnblogs.com/lyxdw/p/8908532.html
Copyright © 2011-2022 走看看