当前位置 : 主页 > 网页制作 > html >

左侧标签

来源:互联网 收集:自由互联 发布时间:2021-06-12
!DOCTYPE htmlhtml lang="zh-CN"head meta charset="UTF-8" titleTitle/title style * { margin: 0; padding: 0; } .menu-items{ text-align: center; border-bottom: 1px solid #23282e; background-color: #181c20; } ul { margin: 0; padding: 0; list-sty
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .menu-items{
            text-align: center;
            border-bottom: 1px solid #23282e;
            background-color: #181c20;
        }
        ul {
            margin: 0;
            padding: 0;
            list-style-type: none;
        }

        .right{
            width: 80%;
            height: 100%;
        }
        .left {
            position: fixed;
            background-color: #23282e;
            width: 20%;
            height: 100%;
        }

        .menu-title{
            text-align: center;
            border-bottom: 1px solid #23282e;
        }
        .hide{
            display: none;
        }
        .menu{
            color: white;
        }
        a{
            color: white;
          text-decoration: none;
        }
        li{
            margin: 0;
            padding: 0;
           border-bottom: 1px solid #23282e;
        }
    </style>

</head>

<body>
<div class="left">
    <div class="menu">
        <div class="menu-title">menu1</div>
        <div class="menu-items hide">
            <ul>
                <li><a href="https://www.baidu.com">111</a></li>
                <li><a href="https://www.baidu.com">222</a></li>
                <li><a href="https://www.baidu.com">333</a></li>
            </ul>
        </div>
        <div class="menu-title">menu2</div>
        <div class="menu-items hide">
            <ul>
                <li><a href="https://www.baidu.com">111</a></li>
                <li><a href="https://www.baidu.com">222</a></li>
                <li><a href="https://www.baidu.com">333</a></li>
            </ul>
        </div>
        <div class="menu-title">menu3</div>
        <div class="menu-items hide">
            <ul>
                <li><a href="https://www.baidu.com">111</a></li>
                <li><a href="https://www.baidu.com">222</a></li>
                <li><a href="https://www.baidu.com">333</a></li>
            </ul>
        </div>
    </div>

</div>
<div class="right"></div>
<script src="jquery-3.4.1.js"></script>
<script>
    $(‘.menu-title‘).click(
        function () {
            var $currentMenuitem = $(this).next();
            $(".menu-items").not($currentMenuitem).addClass(‘hide‘);
            $(this).next().toggleClass(‘hide‘);
        }
    );
</script>

</body>
</html>
网友评论