title: javascript for position fixed on scroll
body: <p>I have this div which is just a title. </p>
  
  <pre><code>&lt;div class="container-fluid DFOCpadding"&gt;
  &lt;div class="row"&gt;
      &lt;div class="col-lg-12"&gt;
          &lt;div class=" text-center "&gt;
          &lt;span class="toptext"&gt;DANCE FOR OVARIAN CANCER&lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>and a nav bar under it which I'd like to position as fixed </p>
  
  <pre><code>&lt;nav class="navbar navbar-default"&gt;
  &lt;div class="container"&gt; 
      &lt;div class="navbar-header page-scroll"&gt;
          &lt;button type="button" class="navbar-toggle glyphicon glyphicon-chevron-down" data-toggle="collapse" data-target="#navbar"&gt;
              &lt;span class="sr-only"&gt;Dance Dance&lt;/span&gt;
          &lt;/button&gt;
      &lt;/div&gt;
      &lt;div class="collapse navbar-collapse" id="navbar"&gt;
          &lt;ul class="nav navbar-nav"&gt;
              &lt;li&gt;&lt;a href="http://danceforovariancancer.com.au"&gt;HOME&lt;/a&gt;&lt;/li&gt;             
              &lt;li&gt;&lt;a class="scroll" href="#register"&gt;&lt;span class="register"&gt;REGISTER&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a class="scroll" href="#faq"&gt;FAQ's&lt;/a&gt;&lt;/li&gt;    
              &lt;li&gt;&lt;a class="scroll" href="#acts"&gt;ACTS&lt;/a&gt;&lt;/li&gt;    
              &lt;li&gt;&lt;a class="scroll" href="#about"&gt;ABOUT&lt;/a&gt;&lt;/li&gt;  
              &lt;li&gt;&lt;a class="scroll" href="#contact"&gt;CONTACT&lt;/a&gt;&lt;/li&gt;      
          &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/nav&gt;  
  </code></pre>
  
  <p>and I need the page to just catch the navbar when you scroll past it like on this site: <a href="https://ovariancancer.net.au/" rel="noreferrer">https://ovariancancer.net.au/</a></p>
  
  <p>I have seen answers for this but they are very restricted to the OP's use case and so I can't get it to work for my page. </p>
  
  <p>cheers</p>