title: How do I vertically center align a position:relative element?
body: <p>How do I vertically center align the <strong>parent container</strong> to the canvas which has  <code>position:relative</code>? The parent container has a child element with <code>position:absolute</code>. The child element has been positioned in the center of the parent container.</p>
  
  <p>Here's a snippet:</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>.container {
    position: relative;
    width: 300px;
    height: 300px;
    background-color: red;
    margin: auto;
  }
  
  .item {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: blue;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;div class="item"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>