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

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:

    Two aligned blocks

  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

posted @ 2015-07-24 09:48  webglcn  阅读(753)  评论(0编辑  收藏  举报