>  Q&A  >  본문

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>


小白小白2783일 전1247

모든 응답(2)나는 대답할 것이다

  • 数据分析师

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

    HTML 루트 글꼴을 매우 큰 값으로 설정한 후 인라인 요소를 감싸는 div가 설명할 수 없을 정도로 커지는 이유는 무엇입니까? -PHP 중국어 웹사이트 Q&A-HTML 루트 글꼴을 매우 큰 값으로 설정한 후 인라인 요소를 감싸는 div가 설명할 수 없을 정도로 커지는 이유는 무엇입니까? -PHP 중국어 홈페이지 Q&A

    꼭 보고 배워보세요.

    회신하다
    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,详情百度一下差异

    회신하다
    0
  • 취소회신하다