图片和文字垂直居中

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        .box {
            display: table;
        }
        
        .box>span,
        .box>div {
            display: table-cell;
            vertical-align: middle;
            line-height: 0
        }
    </style>
</head>

<body>
    <div class="box">
        <span>dkfjkfdk</span>
        <div>
            <img src="img/1.png" alt="">
        </div>
    </div>
</body>

</html>

  

posted @ 2018-01-11 11:36  莫笑我胡为  阅读(314)  评论(0编辑  收藏  举报