Edit in JSFiddle

<div class="container">
  <div class="box">
    This is an example <br>
    of a variable height <br>
    element being aligned vertically.
  </div>
</div>
html, body { height: 100%; }

.container {
  position: relative;
  text-align: center;
  display: block;
  height: 100%;
  
  &::before,
  .box {
    display: inline-block;
    vertical-align: middle;
    border: 1px solid red;
  }

  &::before {
    content: '';
    width: 0;
    height: 100%;
  }
}