Lego2012
9/26/2016 - 9:45 PM

Align Content vertically using absolute Positioning

Align Content vertically using absolute Positioning

* {
  padding: 10px 20px;
}

.container {
  position: relative;
  height: 6em;
  width: 300px;
  background: #e5e6e5;
  margin-left: auto;
  margin-right: auto;
}

.content {
  position: absolute;
  color: #fff;
  top: 3em;
  line-height: 3em;
  margin-top: -1.5em;
  background: #7396a1;
}
<div class="container">
  <div class="content">I'm aligned vertically!</div>
</div>