• css的多级分类


    
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    </head>
    <style>
    .option:after{
    clear: both;
    content: '';
    display: block;
    }
    .option li{
    float: left;
    height:100px;
    200px;
    background-color: gray;
    margin-right: 50px;
    }
    ul,li{
    list-style: none;
    }

    .option li.on{
    background-color: orange;
    }


    .con1{
    500px;
    height:100px;
    background-color: yellowgreen;
    position: relative;
    }
    .con1 .con1-li{
    500px;
    height:100px;
    position: absolute;
    z-index: -1;
    opacity: 0;
    }
    .con1 .con1-li.on{
    z-index: 1;
    opacity: 1;
    }
    .con2 li{
    background-color: red;
    margin:5px 0;
    }
    .con2 li.on{
    background-color: pink;
    }
    .con3{
    height:100px;
    500px;
    background-color: #00a0e9;
    position: relative;
    }
    .con3 li{
    height:100px;
    500px;
    position: absolute;
    z-index: -1;
    opacity: 0;
    }
    .con3 li.on{
    z-index: 1;
    opacity: 1;
    }
    </style>
    <body>

    <ul class="option">
    <li class="on">1</li>
    <li>2</li>
    <li>3</li>
    </ul>


    <!--一级分类-->
    <div class="con1">
    <div class="con1-li on">
    <ul class="con2">
    <li class="on">1-1</li>
    <li>1-2</li>
    <li>1-3</li>
    </ul>

    <ul class="con3">
    <li class="on">1-1-value</li>
    <li>1-2-value</li>
    <li>1-3-value</li>
    </ul>
    </div>

    <div class="con1-li">
    <ul class="con2">
    <li class="on">2-1</li>
    <li>2-2</li>
    <li>2-3</li>
    </ul>

    <ul class="con3">
    <li class="on">2-1-value</li>
    <li>2-2-value</li>
    <li>2-3-value</li>
    </ul>
    </div>

    <div class="con1-li">
    <ul class="con2">
    <li class="on">3-1</li>
    <li>3-2</li>
    <li>3-3</li>
    </ul>

    <ul class="con3">
    <li class="on">3-1-value</li>
    <li>3-2-value</li>
    <li>3-3-value</li>
    </ul>
    </div>
    </div>


    <script>
    $(function(){
    $(".option li").hover(function(){
    $(".option li").removeClass("on");
    $(this).addClass("on");

    //
    var the_index = $(".option li").index(this);

    $(".con1 .con1-li").removeClass('on');
    $(".con1 .con1-li").eq(the_index).addClass('on');
    },function(){

    });

    $(".con2 li").hover(function(){
    $(this).parent().children('li').removeClass("on");
    $(this).addClass("on");

    var the_index = $(this).parent().children('li').index(this);
    console.log(the_index);
    $(this).parent().next().children('li').removeClass('on');
    $(this).parent().next().children('li').eq(the_index).addClass('on');
    },function(){

    });
    });
    </script>
    </body>
    </html>
     

  • 相关阅读:
    asp.net中读取带有加号(+)的Cookie,会自动把加号替换为空格
    简单实现分行输出的javascript代码
    大学我们应该做什么
    近日个人要闻
    WPF学习笔记“路由事件”一:路由事件基础
    WPF学习笔记“路由事件”二:路由事件基础
    WPF学习笔记“命令”三:执行命令
    WPF学习笔记“命令”二:命令库
    WPF学习笔记“命令”五:自定义高级命令的使用
    WPF学习笔记“布局”一:基础
  • 原文地址:https://www.cnblogs.com/cl94/p/10629733.html
Copyright © 2020-2023  润新知