taufook
5/1/2017 - 11:40 AM

Vertically center an image.

Vertically center an image.

div{
  width: 300px;
  height: 250px;
  background: #fff;
  position: relative;
}
img{
  width: 100px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%); /* OR margin-top: -50px; half the size of image */
}