title: How to prevent a centered aligned flex item from going up as its height increases?
body: <p>I'm trying to build a dropdown menu, but its div (which is position static) keeps going up as I add new items to the menu.</p>
  <p>It's the <code>align-items:center</code> rule that keeps repositioning the item so it's properly vertically aligned.</p>
  <p>If I discard this rule, it'll break the navbar, the other items won't be centered as I intended.</p>
  <p>If I use the <code>display</code> property, as the code bellow shows, the button starts where I want but whenever I click on it, it goes out of its place.</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-js lang-js prettyprint-override"><code>const dropdown = () =&gt; {
      let display = document.getElementById("menu").style.display;
      
      document.getElementById("menu").style.display = (display === "none") ? "block":"none";
      //toggling "visibility" takes the div out of its place
   }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.nav {
      display: flex;
      justify-content: center;
      align-items: center;
      height:160px;
      border:1px solid black;
      text-align: center;    
  }
  
  .dropdownContainer {
      margin-left: auto;
  }
  
  #drop {
    display:none;
    /* visibility:hidden;*/
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;nav class="nav"&gt;
      &lt;div&gt;Irrelevant elements to this question&lt;/div&gt;
      &lt;div class="dropdownContainer"&gt;
          &lt;button onclick="dropdown()" class="dropdownBtn"&gt;Ronaldinho&lt;/button&gt; 
          &lt;div id="menu"&gt;
              &lt;!-- the more items added here, the more up the page the whole container goes --&gt;
              &lt;div&gt;One&lt;/div&gt;
              &lt;div&gt;Two&lt;/div&gt;
              &lt;div&gt;Three&lt;/div&gt;
              &lt;div&gt;Four&lt;/div&gt;
              &lt;div&gt;Five&lt;/div&gt;
              &lt;div&gt;Six&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/nav&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>If I change the JS code so it toggles the <code>visibility</code> property instead, the button already starts out of its intended position but it also doesn't change place when its clicked on.</p>
  <p>How can I keep the button centered as it is and make the menu drop down without changing the button's place?</p>