Multilevel (up to 3 level) Vertical Menu with bootstrap/Jquery

前端 未结 2 2160
逝去的感伤
逝去的感伤 2021-01-04 11:45

I am trying to create a navigation menu which is vertical and up to 3-level navigation and last level is toggable menu (when u click on last level menu,a set of submenu appe

2条回答
  •  一向
    一向 (楼主)
    2021-01-04 11:58

    you can make it like your screenshot: http://codepen.io/MaGiO/pen/YXXzeJ

    HTML

    Title Page

    CSS

        html{
            height:100%; /* make sure it is at least as tall as the viewport */
        }
        body{
            height:100%; /* force the BODY element to match the height of the HTML element */
            position: relative;
        }
        .dropdown-submenu {
            border-bottom: 1px solid #ccc;
        }
        #mn-wrapper {
          display: table;
          width: 100%;
          position: absolute;
          height: 100%;
        }
        .mn-sidebar {
          display: table-cell;
          position: relative;
          vertical-align: top;
          padding-bottom: 49px;
          background: #272930;
          width: 216px;
          z-index: 2;
        }
        #mn-cont {
          display: table-cell;
          vertical-align: top;
    
          position: relative;
          padding: 0;
        }
        .container {
          margin-right: auto;
        }
        .cnt-mcont {
          background-color: #F6F6F6;
          color: inherit;
          font-size: 13px;
          font-weight: 200;
          line-height: 21px;
          padding: 15px 30px 30px 30px;
          margin-top: 0;
          height: 101vh;
        }
        .mn-sidebar .mn-toggle {
          display: none;
          padding: 10px 0;
          text-align: center;
          cursor: pointer;
        }
        .mn-vnavigation {
          margin: 0 0 0 0;
          padding: 0;
          border-top: 1px solid #1a1c20;
          border-bottom: 1px solid #2f323a;
        }
        .mn-vnavigation li a {
          border-top: 1px solid #32353e;
          border-bottom: 1px solid #1a1c20;
          display: block;
          padding: 14px 18px 13px 15px;
          color: #fff;
          text-decoration: none;
          font-size: 12px;
          font-weight: 300;
          text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
          white-space: nowrap;
        }
        .dropdown-submenu > .dropdown-menu {
            top: 0;
            left: 100%;
            margin-top: -6px;
            margin-left: -1px;
            height: 101vh;
            width: 216px;
            background: #272930;
        }
        .dropdown-submenu:hover > .dropdown-menu {
            display: block;
        }
        .dropdown-submenu > a:after {
            display: block;
            content: " ";
            float: right;
            width: 0;
            height: 0;
            border-color: transparent;
            border-style: solid;
            border-width: 5px 0 5px 5px;
            border-left-color: #ccc;
            margin-top: 5px;
            margin-right: -10px;
        }
        .dropdown-submenu:hover > a:after {
            border-left-color: #fff;
        }
        .dropdown-submenu.pull-left {
            float: none;
        }
        .dropdown-submenu.pull-left > .dropdown-menu {
            left: -100%;
            margin-left: 10px;
            -webkit-border-radius: 6px 0 6px 6px;
            -moz-border-radius: 6px 0 6px 6px;
            border-radius: 6px 0 6px 6px;
        }
        ul {
            list-style: none;
        }
    

    JS

    $('.child').hide(); //Hide children by default
    
        $('.parent').children().click(function () {
            event.preventDefault();
            $(this).children('.child').slideToggle('slow');
            $(this).find('span').toggle();
        });
    

    you want something like this?

提交回复
热议问题