Div 内部所有元素 全部垂直对齐
http://stackoverflow.com/questions/7273338/how-to-vertically-align-an-image-inside-div
How it works:
-
When you have two
inline-block
elements near each other, you can align each to other's side, so withvertical-align: middle
you'll get something like this: -
When you have a block with fixed height (in
px
,em
or other absolute unit), you can set the height of inner blocks in%
. - So, adding one
inline-block
withheight: 100%
in a block with fixed height would align anotherinline-block
element in it (<img/>
in your case) vertically near it.
div内部所有元素都添加vertical-align: middle
; display:inline-block