• css中选项卡的实现


    制作一个简单的选项卡,以供初学者参考;关于css书写的比较粗糙。请见谅

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>选项卡</title>
    <style>
    *{margin:0;padding:0;}
    a{text-decoration:none;}
    li{list-style: none;}
    #box{
    510px;
    height:400px;
    border:2px solid yellow;
    }
    .content{
    510px;
    height:300px;
    overflow:hidden;
    }
    .a1{
    510px;
    height:300px;
    background:#ccc;
    display: none;
    }
    .a2{
    510px;
    height:300px;
    background:red;
    display:none;
    }
    .a3{
    510px;
    height:300px;
    background:black;
    display:none;
    }
    .a4{
    510px;
    height:300px;
    background:blue;
    display:none;
    }
    .a5{
    510px;
    height:300px;
    background:#565656;
    display:none;
    }
    .content .active{
    display:block;

    }
    #box-title li{
    100px;
    height:100px;
    float:left;
    text-align:center;
    border:1px solid yellow;

    }
    </style>
    <script src="http://cdn.bootcss.com/jquery/1.8.3/jquery.js"></script>
    <script >

      

    (function($){
    $(function(){
    var Li=$('#box-title li');
    Li.click(function(){

    var iIndex=$(this).index();
    Li.removeClass('active').eq(iIndex).addClass('active');
    $('.content div').removeClass('active').eq(iIndex).addClass('active');
    console.log(1);
    });
    });
    })(jQuery);

    </script>
    </head>
    <body>
    <div id="box">
    <ul id="box-title">
    <li class="active">第一部分</li>
    <li>第二部分</li>
    <li>第三部分</li>
    <li>第四部分</li>
    <li>第五部分</li>
    </ul>
    <div class="content">
    <div class="a1 active">1</div>
    <div class="a2">2</div>
    <div class="a3">3</div>
    <div class="a4">4</div>
    <div class="a5">5</div>
    </div>

    </div>

    </body>
    </html>

  • 相关阅读:
    c#将 1, 2, ..., 9共 9 个数字分成 3 组
    信息学院本科生创新项目总结
    Element-ui的使用
    fastmock接口管理
    mock安装与使用
    开闭原则
    里氏替换原则
    依赖倒置原则
    接口隔离原则
    单一职责原则
  • 原文地址:https://www.cnblogs.com/jack-lin/p/6431318.html
Copyright © 2020-2023  润新知