Search code examples
twitter-bootstrapfixednavbar

Fixed navbar will not work on mobile


I've got a problem in getting menu being fixed on Mobile(small screen) view. I've tried working around this several hours, and tried all the common tricks (position:fixed etc). Even the standard twitter-bootstrap template for a fixed navbar: (http://getbootstrap.com/examples/navbar-fixed-top/) is not fixed.

Is the position:fixed support dropped on mobile?

Edit: The jquery mobile fixed navbars are working, but neither of the ordinary solutions.


Solution

  • Use this code sample.

    <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
          <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-6">
            <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="#">Brand</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-6">
          <ul class="nav navbar-nav">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#">Link</a></li>
            <li><a href="#">Link</a></li>
          </ul>
        </div>
      </nav>