<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>42度空间-利用grid布局实现元素水平垂直居中</title>
    <style>
        .parent {
            height: 140px;
            display: grid;
            align-items:center;
            border: 2px dashed #f69c55;
        }
        .child {
            margin:auto;
            padding: 20px;
            width:10rem;
            color: #fff;
            background: black;
        }
    </style>
</head>
<body>
<div class="parent">
    <div class="child">好的程序员能写出人能读懂的代码。</div>
</div>
</body>
</html>