Bootstrap 引导程序3和mmenu

r1wp621o  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(185)

我想实现mmenu到Bootstrap 3,但我卡住了。我想有顶部导航,当折叠我想它改变为左滑动菜单。提前感谢帮助。
编辑:我做了这个:https://github.com/purgeru/mmenu-Bootstrap-3。如果有人想贡献。

4xy9mtcn

4xy9mtcn1#

This can be done without mmenu , adding a bit of CSS.
I would suggest you to create 2 differents nav :

Commented example :

<!-- Classic nav -->
<div class="navbar navbar-fixed-top navbar-inverse" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <!-- We change data-toggle to "offcanvas" -->
      <button type="button" class="navbar-toggle" data-toggle="offcanvas">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Project name</a>
    </div>
    <div class="collapse navbar-collapse">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#about">About</a></li>
        <li><a href="#contact">Contact</a></li>
      </ul>
    </div>
  </div>
</div>

<div class="container">

  <!-- You can use .row-offcanvas-left or .row-offcanvas-right -->
  <div class="row row-offcanvas row-offcanvas-left">

    <!-- Here is the offcanvas nav, with .visible-xs class -->
    <div class="col-xs-6 visible-xs sidebar-offcanvas" id="sidebar" role="navigation">
      <div class="list-group">
        <a href="#" class="list-group-item active">Home</a>
        <a href="#" class="list-group-item">About</a>
        <a href="#" class="list-group-item">Contact</a>
      </div>
    </div>

    <div class="col-12">
      Content
    </div>

  </div>

</div>

You'll need a few CSS :

/*
 * Off Canvas
 * --------------------------------------------------
 */
@media screen and (max-width: 767px) {
  .row-offcanvas {
    position: relative;
    -webkit-transition: all 0.25s ease-out;
    -moz-transition: all 0.25s ease-out;
    transition: all 0.25s ease-out;
  }

  .row-offcanvas-right .sidebar-offcanvas { right: -50%; }
  .row-offcanvas-right .sidebar-offcanvas .list-group { padding-right: 10px; }
  .row-offcanvas-right.active { right: 50%; }

  .row-offcanvas-left .sidebar-offcanvas { left: -50%; }
  .row-offcanvas-left .sidebar-offcanvas .list-group { padding-left: 10px; }
  .row-offcanvas-left.active { left: 50%; }

  .sidebar-offcanvas {
    position: absolute;
    top: 0;
    width: 50%; /* 6 columns */
  }
}

And a few lines of JS :

$(document).ready(function() {
  $('[data-toggle=offcanvas]').click(function() {
    $('.row-offcanvas').toggleClass('active');
  });
});

相关问题