html css div img垂直居中

 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
 <style type="text/css">
    div{
        height:200px;
        background:#eee;
        vertical-align:middle;
    }
    img{
        height:40px;
        vertical-align:middle;
    }
    /* span{
        height:100%;
        display:inline-block;
        vertical-align:middle;
    }     */
 </style>
 <body>
  <div>
    <!-- <span></span> -->
    <img src="https://www.baidu.com/img/bd_logo1.png" alt="" />
  </div>
 </body>

 

posted @ 2017-05-04 10:58  西瓜霜  阅读(859)  评论(0编辑  收藏  举报