div中img和a链接同时居中

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>div中img垂直居中</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="" />
    <a style="vertical-align: middle">徐同保</a>
</div>
</body>

posted @ 2017-10-16 15:29  徐同保  阅读(765)  评论(0编辑  收藏  举报