search

Home  >  Q&A  >  body text

html根字体设置成很大的值后, 包裹了行内元素的div莫名变高是什么原因?

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <style>
    html {
        font-size: 100px;
    }
    span {
        font-size: 12px;
        line-height: 12;
    }
    </style>
</head>
<body>
    <div>
    <span>dsflfij</span>
    </div>
</body>
</html>


小白小白2823 days ago1286

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:41:29

    After setting the html root font to a very large value, why does the div that wraps the inline elements become inexplicably taller? -PHP Chinese website Q&A-After setting the HTML root font to a very large value, why does the div that wraps the inline elements become inexplicably taller? -PHP Chinese website Q&A

    Let’s take a look and learn.

    reply
    0
  • 迷茫

    迷茫2017-03-07 09:29:01

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    
        <style>
        html {
            font-size: 100px;
        }
        span {
            font-size: 12px;
            line-height: 12;
        }
        </style>
    </head>
    <body>
        <div>
        <span>dsflfij</span>1
        </div>
    </body>
    </html>

    因为font-size可继承,你这样写了后div的font-size也变大了。

    并且需要注意的一点line-height里面 12 != 12px,详情百度一下差异

    reply
    0
  • Cancelreply