title: Bootstrap 3 - How do I make the nav bar sticky on scroll
body: <p>What I am trying to do is make the nav bar stay at the top of the page when you scroll past it. As I am quite new to JavaScript I looked a few tutorials, however, none of them really worked with the Bootstrap nav bar. I was just wondering if there was a way to do this so that it works with the Bootstrap columns. </p>
  
  <p>Also how could I make it so that while it's scrolling, the background colour starts to fade in?</p>
  
  <p>Here is the HTML code for the nav bar, in case that helps:</p>
  
  <pre><code>   &lt;div class="container"&gt;
      &lt;nav class="navbar navbar-default" id="mNavbar"&gt;
        &lt;div class="container"&gt;
          &lt;div class="navbar-header"&gt;
            &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false" id="toggle"&gt;
              &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
              &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;span class="icon-bar"&gt;&lt;/span&gt;
            &lt;/button&gt;
          &lt;/div&gt;
  
          &lt;div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"&gt;
            &lt;ul class="nav navbar-nav"&gt;
              &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#section2"&gt;Services&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="#section3"&gt;Contact&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/nav&gt;
    &lt;/div&gt;
  </code></pre>