title: How can I make multiple on scroll fixed headers/navbars that stick at the very top of the page?
body: <p>Does anyone know how to make multiple on scroll fixed headers? I've already checked answers such as <a href="https://stackoverflow.com/questions/7385068/freeze-header-until-irrelevant-html-css-and-js/">this</a>.</p>
  <p>I want the first header, that's already fixed at the top of the screen, to stop <strong>before</strong> the second header, and when the first header gets scrolled past, the second header should be taking the first header's place and stick at the very top of the screen.</p>
  <p>But such answers don't work for me because they're using libraries that I'm not working with, such as jQuery, or they are overly, overly complicated. I've got it to work, so far, with <code>getBoundingClientRect()</code>, but with only 2 headers.</p>
  <p>I've provided the HTML&amp;CSS part here:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Roboto', sans-serif;
  }
  
  @import url("https://fonts.googleapis.com/css?family=Roboto:100");
  
  h1 {
    letter-spacing: 3px;
    margin: 0;
    padding-left: 10px;
    padding-top: 10px;
    color: #fff;
    font-weight: 100;
  }
  
  .header {
    width: 100%;
    height: 50px;
  }
  
  .header:nth-of-type(1){
     background-color: dodgerblue;
      position: fixed;
  }
  
  .header:nth-of-type(2){
     background-color: rebeccapurple;
  }
  
  .header:nth-of-type(3){
     background-color: chartreuse;
  }
  
  .content {
    width: 100%;
    height: 100%;
    background: linear-gradient(70deg, orange, crimson);
    padding-top: 50px;
      
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;header class="header"&gt;&lt;h1&gt;HEADER 1&lt;/h1&gt;&lt;/header&gt;
  &lt;div class="content"&gt;&lt;h1&gt;CONTENT&lt;/h1&gt;&lt;/div&gt;
  &lt;header class="header"&gt;&lt;h1&gt;HEADER 2&lt;/h1&gt;&lt;/header&gt;
  &lt;div class="content"&gt;&lt;h1&gt;CONTENT&lt;/h1&gt;&lt;/div&gt;
  &lt;header class="header"&gt;&lt;h1&gt;HEADER 3&lt;/h1&gt;&lt;/header&gt;
  &lt;div class="content"&gt;&lt;h1&gt;CONTENT&lt;/h1&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>