css之div中纯文字单行和多行垂直居中

先上效果图

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .wrap1 {
             200px;
            height: 200px;
            background: red;
            line-height: 200px;
        }

        .wrap2 {
             200px;
            height: 200px;
            background: blue;
            display: table-cell;
            vertical-align: middle;
        }
    </style>
</head>

<body>
    <div class="wrap1">
        wrap1中的文字.
    </div>
    <div class="wrap2">
        wrap2中的文字,wrap2中的文字,wrap2中的文字,wrap2中的文字,wrap2中的文字。
    </div>
</body>

</html>
原文地址:https://www.cnblogs.com/samsara-yx/p/12394604.html