create a vertical affixed navigation menu - HTML CSS Bootstrap

HTML CSS examples for Bootstrap:Navbar

Description

create a vertical affixed navigation menu

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
  .affix {<!--  w ww  .j  a  va  2s  .c  o  m-->
      top: 20px;
      z-index: 9999 !important;
  }
  </style>
</head>
<body>

<div class="container-fluid" style="background-color:#2196F3;color:#fff;height:200px;">
  <h1>Bootstrap Affix Example</h1>
  <h3>Fixed (sticky) vertical sidenav on scroll</h3>
  <p>This is a test. This is a test. This is a test.</p>
  <p>This is a test. This is a test. This is a test.</p>
</div>
<br>

<div class="container">
  <div class="row">
    <nav class="col-sm-3">
      <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="205">
        <li class="active"><a href="#section1">Section 1</a></li>
        <li><a href="#section2">Section 2</a></li>
        <li><a href="#section3">Section 3</a></li>
      </ul>
    </nav>
    <div class="col-sm-9">
      <h1>Some text to enable scrolling</h1><br/><br/>

      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
      <h1>Some text to enable scrolling</h1><br/><br/>
    </div>
  </div>
</div>

</body>
</html>

Related Tutorials