http://stackoverflow.com/questions/7273338/how-to-vertically-align-an-image-inside-div

How it works:

  1. When you have two inline-block elements near each other, you can align each to other's side, so with vertical-align: middle you'll get something like this:

    Div 内部所有元素 全部垂直对齐

  2. When you have a block with fixed height (in px, em or other absolute unit), you can set the height of inner blocks in %.

  3. So, adding one inline-block with height: 100% in a block with fixed height would align another inline-block element in it (<img/> in your case) vertically near it.

  div内部所有元素都添加vertical-align: middle; display:inline-block

相关文章: