twitter-bootstraptwitter-bootstrap-3navigationmmenu

Bootstrap 3 and mmenu


I would like to implement mmenu to Bootstrap 3 but I'm stuck. I want to have the top navigation and when collapsing I want it to change to left sliding menu. Thanks in advance for the help.

EDIT: I made this: https://github.com/purgeru/mmenu-Bootstrap-3. If someone wants to contribute.


Solution

  • This can be done without mmenu, adding a bit of CSS.

    I would suggest you to create 2 differents nav :

    See this Bootply for a working example, based on Offcanvas template.

    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');
      });
    });