css table布局实现左右上下居中

2019-01-30  本文已影响0人  shibin
<!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>test</title>
    <style>
        html,
        body {
            height: 100%;
        }

        .table {
            display: table;
            margin: 0 auto;
            height: 100%;
        }

        .item {
            display: table-cell;
            height: 100%;
            vertical-align: middle;//垂直居中

        }

        .item.left {
            text-align: right;//左侧第一列右对齐
            padding-right: 10px;
        }
    </style>
</head>

<body>
    <div class="table">
        <div class="item left">
            <div>哈哈哈你 :</div>
            <div>哈哈哈你递四方速递:</div>
            <div> 范德萨范德萨发:</div>
        </div>
        <div class="item">
            <div>100问你</div>
            <div>佛挡杀佛 </div>
            <div> fdsafsad</div>
        </div>
    </div>
</body>
</html>

上一篇下一篇

猜你喜欢

热点阅读