Lego2012
9/26/2016 - 10:08 PM

Vertical middle align

Vertical middle align

/*
Here first set the element position relative so we can set its position thought top and left.
Then set top 50% so element position set his parent  height of 50%. Now we only need to minus
element half height as defined above minus margin but in margin method we need to define height
of the element.
*/

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