inline-flex 遇上子层字体不和父层一样, 会产生多余的空隙

这次的坑是和父层字体不一致, 原理我不清楚...

workaround 是不要让子层的字体贴着最上方

 

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            margin: 10px;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .parent {
            font-size: 16px;
            display: inline-flex;
            width: 100%;
            border: 1px solid red;
        }

        .child {
            font-size: 12px;
            /* padding-top: 10px; */
        }
    </style>
</head>

<body>
    <div class="parent">
        <div class="child">
            child
        </div>
    </div>
    <div class="parent">
        <div class="child">
            child
        </div>
    </div>
</body>

</html>
View Code

 

posted @ 2021-02-03 11:22  泉油  阅读(168)  评论(0编辑  收藏  举报
Web Design Johor Bahru Malaysia - Stooges