Materialize: side-nav links doesn't works in fixed navbar

Created on 7 Dec 2016  ·  6Comments  ·  Source: Dogfalo/materialize

I have a navbar with brand logo at left and links at right, and the sidenav function works perfect.
I tried to make the navbar fixed, but now the sidenav links doesn't works (the sidenav appears in grey color)

Code

  <div class="navbar-fixed">
    <nav class="green">
      <div class="nav-wrapper">
        <a href="/" class="brand-logo">
          <i class="material-icons">shopping_basket</i>
          macromeal
        </a>
        <a href="#" data-activates="mobile-demo" class="button-collapse">
          <i class="material-icons">menu</i>
        </a>
        <ul class="right hide-on-med-and-down">
          <%= render 'layouts/links' %>
        </ul>
        <ul class="side-nav" id="mobile-demo">
          <%= render 'layouts/links' %>
        </ul>
      </div>
    </nav>
  </div>

Screenshot
image

Most helpful comment

Please try moving the side-nav out of the navbar structure. Like this:

  <div class="navbar-fixed">
    <nav class="green">
      <div class="nav-wrapper">
        <a href="/" class="brand-logo">
          <i class="material-icons">shopping_basket</i>
          macromeal
        </a>
        <a href="#" data-activates="mobile-demo" class="button-collapse">
          <i class="material-icons">menu</i>
        </a>
        <ul class="right hide-on-med-and-down">
          <%= render 'layouts/links' %>
        </ul>
      </div>
    </nav>
  </div>
  <ul class="side-nav" id="mobile-demo">
    <%= render 'layouts/links' %>
  </ul>

Not exactly sure but in principle this works. :smiley:

All 6 comments

Yes same problem.

Please try moving the side-nav out of the navbar structure. Like this:

  <div class="navbar-fixed">
    <nav class="green">
      <div class="nav-wrapper">
        <a href="/" class="brand-logo">
          <i class="material-icons">shopping_basket</i>
          macromeal
        </a>
        <a href="#" data-activates="mobile-demo" class="button-collapse">
          <i class="material-icons">menu</i>
        </a>
        <ul class="right hide-on-med-and-down">
          <%= render 'layouts/links' %>
        </ul>
      </div>
    </nav>
  </div>
  <ul class="side-nav" id="mobile-demo">
    <%= render 'layouts/links' %>
  </ul>

Not exactly sure but in principle this works. :smiley:

wow its working

Daniel Bendel notifications@github.com于2016年12月8日周四 下午10:32写道:

Please try moving the side-nav out of the nav. Like this:



    <%= render 'layouts/links' %>

Not exactly sure but in principle this works. 😃


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Dogfalo/materialize/issues/3982#issuecomment-265753284,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJEkgwq_VDbLF5WNLRcJeNrQMF5aVExQks5rGBTqgaJpZM4LHMBm
.

Thanks @Thanood ! I will try it.
Btw, I already fixed it by this way:

function initialize() {
  $('.button-collapse').sideNav();
  $('.button-collapse').click(removeOverlay);
}

function removeOverlay() {
  $('div[id^=sidenav-overlay]').remove();
}

Oops, sorry @tomscholz . I searched but I didn't find it

Was this page helpful?
0 / 5 - 0 ratings