栖云楼


Vertical align an unknown size image

2016-03-27

Some ways to vertiacl align an image in a div, the image’s width and height are unknown

  • Use a helper incline-block div to vertica the image. The helper’s width is 0
  • Use a tricky way top, right, bottom, left all 0 and margin auto
  • Use css transform translateY

demo