Vertical Align Content Without Using Display Table

  • CSS

The following code will allow you to vertically center content in a box, without having to use the css display properties of table and table-cell.

.parent-element {
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

.element {
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}

reference: http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/

Close Menu