Vertical align

Version with absolute position:

Preview: https://jsfiddle.net/k3goLtfc/

html:

<div class="wrapper">
  <div class="aligned">
    aligned
  </div>
</div>

css:

.wrapper {
  position: relative;
  height: 100px;
  background-color: yellow;
}

.aligned {
  background-color: cyan;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

Leave a Reply

Your email address will not be published. Required fields are marked *