title: Center image vertically in div using only css
body: <p>I'm trying to center an image which is contained in a div with display set to table. In it, I wish to display an image, which should be positioned in the center, both vertically and horizontally. I have achieved the horizontal position using margin:auto and setting it as display: table-cell, but it doesn't center it vertically. Any help would be great </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>.overlay { height: 50%; background: red;position: fixed;
  top: 0;
  left: 0;
  height: 50%;
  width: 100%;
  display: table;}
  .swipe {height: 80px;
  display: table-cell;
  margin: auto;}</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style="height:300px"&gt;
  &lt;div class="overlay"&gt;
     &lt;img class="swipe" src="https://d30y9cdsu7xlg0.cloudfront.net/png/255751-200.png" /&gt;</code></pre>
  </div>
  </div>
  </p>