html - 为什么 SPAN 的高度大于它的字体大小

标签 html css

我不明白为什么 span 元素的高度大于它的字体大小(边距和填充 = 0):JSFiddle example

<head>
    <style>
        .analized-element {
            font-size: 20px;
            font-family: "Lucida Console", "Lucida Grande", monospace;
        }
    </style>

</head>
<body>
    <span class="analized-element">Test message</span>
</body>

此问题仅在 Mac 中存在:

== analized-element =====
border-size: 0 0 0 0
padding: 0 0 0 0
font-size: 20px
offsetHeight: 23px
=========================

我们如何看到有 3 个额外的像素。 Windows 中的相同示例:

== analized-element =====
border-size: 0 0 0 0
padding: 0 0 0 0
font-size: 20px
offsetHeight: 20px
=========================

span 的高度等于它的字体大小。

最佳答案

@media screen and (max-device-width: 460px){
    body{
        -webkit-text-size-adjust: none;
    }
}

关于html - 为什么 SPAN 的高度大于它的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34357256/

相关文章:

html - 跨越另一个 div 的 CSS 边框

jquery - 将第一个 UL 保留在 div 底部的 UL 中

javascript - Visual Studio Code 中的命令行/窗口

javascript - 显示弹出窗口时在模式弹出窗口中打印内容,但如果隐藏模式弹出窗口则打印正文

css - 溢出-x : scroll not working correctly

html - 将中心位置应用于画廊而不是图片

html - IE8 html图像对齐

html - 基础 block 网格边界高度

javascript - 在图像上添加文字

css - Font Awesome extras.less 变量