title: center div with position absolute with just css without knowing the width
body: <p>I would like to center different images which are shown and hidden, depending on how the user clicks.
  What I did to center an image was:</p>
  
  <pre><code>img { 
    margin-left: auto; 
    margin-right: auto; 
    display: block;
  }
  </code></pre>
  
  <p>which worked fine. But it does not work for a <code>position: absolute;</code> Is there a css only way to center a <code>position: absolute</code> div horizontally in the middle of <code>body</code> or <code>parent</code> without knowing the <code>width</code>?</p>