title: centering form with css with position absolute
body: <p>I am trying to center this form</p>
  
  <p><a href="https://i.stack.imgur.com/YsUNh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YsUNh.png" alt="enter image description here"></a></p>
  
  <p>here is my css:</p>
  
  <pre><code>form {
    background-color: yellow;
    width: 400px;
    position: absolute;
    text-align: center;
    margin-top: 5rem;
    margin-left: auto;
    margin-right: auto;
  }
  </code></pre>
  
  <p>The form will center if I get rid of position absolute however if I remove position absolute the following happens</p>
  
  <p><a href="https://i.stack.imgur.com/DB7Tr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DB7Tr.png" alt="enter image description here"></a></p>
  
  <p>Can't seem to figure it out. </p>