title: sticky topnav but dropdowns do not show
body: <p>I want to make a horizontal navigation bar that is sticky to the top with dropdown menus. The problem is that the dropdown menus no longer show when I make the navigation bar sticky.</p>
  
  <p>I used the following CSS3 to achieve the sticky effect. Is there another way to accomplish the same effect, especially with CSS.</p>
  
  <pre><code>.topnav {
      overflow: hidden;
      background-color: #333;
      position: fixed;         /* This line adds stickyness */
      top: 0;                  /* along with this line here */
      width: 100%;
  }
  </code></pre>
  
  <p>Minimum Problematic Example:</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>body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
  }
  
  .topnav {
    overflow: hidden;
    background-color: #333;
    position: fixed;
    top: 0;
    width: 100%;
  }
  
  .topnav a {
    float: left;
    display: block;
    font-size: 16px;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
  }
  
  .dropdown {
    float: left;
    overflow: hidden;
  }
  
  .dropdown .dropbtn {
    font-size: 16px;
    border: none;
    outline: none;
    color: white;
    padding: 14px 16px;
    background-color: inherit;
    font-family: inherit;
    margin: 0;
  }
  
  .topnav a:hover,
  .dropdown:hover .dropbtn {
    background-color: red;
  }
  
  .dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1;
  }
  
  .dropdown-content a {
    float: none;
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
  }
  
  .dropdown-content a:hover {
    background-color: #ddd;
  }
  
  .dropdown:hover .dropdown-content {
    display: block;
  }
  
  .main {
    padding: 16px;
    margin-top: 30px;
    height: 1500px;
    /* Used in this example to enable scrolling */
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="topnav"&gt;
    &lt;a href="#home"&gt;Home&lt;/a&gt;
    &lt;a href="#news"&gt;News&lt;/a&gt;
    &lt;div class="dropdown"&gt;
      &lt;button class="dropbtn"&gt;Dropdown 
            &lt;b&gt;V&lt;/b&gt;
          &lt;/button&gt;
      &lt;div class="dropdown-content"&gt;
        &lt;a href="#"&gt;Link 1&lt;/a&gt;
        &lt;a href="#"&gt;Link 2&lt;/a&gt;
        &lt;a href="#"&gt;Link 3&lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="main"&gt;
    &lt;h1&gt;Fixed Top Menu&lt;/h1&gt;
    &lt;h2&gt;Scroll this page to see the effect&lt;/h2&gt;
    &lt;h2&gt;The navigation bar will stay at the top of the page while scrolling&lt;/h2&gt;
    &lt;h3&gt;Dropdown Menu inside a Navigation Bar&lt;/h3&gt;
    &lt;p&gt;Hover over the "Dropdown" link to see the dropdown menu.&lt;/p&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Edit:</p>
  
  <p>Thanks to Saeed and dkobando. I am only at the start of my web document journey. I have been slowly piecing together the parts of my site from various guides. I was pleasantly surprised by two helpful prompt answers. Your replies here encourage me to continue my journey.</p>