Bootstrap Tutorial - Bootstrap Scrollable responsive navbar








Scrollable responsive navbar

For instances where you have too many items in your navbar to fight within the viewport of a small device, add .nav-collapse-scrollable to your navbar's .nav-collapse to set a max-height and smooth scrolling.

<!DOCTYPE HTML>
<html>
<head>
<link href="http://java2s.com/style/bootstrap.min.css" rel="stylesheet">
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script src="http://java2s.com/style/bootstrap.min.js"></script>
</head><!--   w ww  .j  a  v  a 2  s .  c  o m-->
<body style='margin: 20px;'>

  <div class="navbar">
    <div class="container">
      <button type="button" class="navbar-toggle" data-toggle="collapse"
        data-target=".bs-navbar-scroll-collapse">
        <span class="icon-bar"></span> <span class="icon-bar"></span> <span
          class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Title</a>
      <div
        class="collapse nav-collapse nav-collapse-scrollable bs-navbar-scroll-collapse">
        <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>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
        </ul>
        <form class="navbar-form pull-left" action="">
          <input type="text" class="form-control col-lg-8"
            placeholder="Search">
        </form>
      </div>
      <!-- /.nav-collapse -->
    </div>
    <!-- /.container -->
  </div>

</body>
</html>

Click to view the demo