html - 为什么 bold monoface 在 Windows 上垂直移动?

标签 html css layout bold monospace

在 Windows 上的 Firefox 3.6、IE7 和 Opera 10 中,此 HTML 有一个奇怪的行为:

<html><head></head>
<style>
span {
    font-family: monospace; background-color: green;
}
span.b {
    font-weight: bold;
}
</style>
<body>
<span>Text</span><span class="b">Text</span><span>Text</span>
</body>
</html>

中间的粗体跨度向下移动了一个像素。其他字体不会发生这种情况。

这是为什么呢?我该如何解决?

最佳答案

Why is that?

好问题。只花了半个小时试图找出原因,无济于事。 Marcgg 的解决方案似乎也不起作用,偏移量仍然存在。谷歌什么也没找到。这似乎只发生在 Windows 上,不仅在您提到的浏览器中,而且在 Opera 9 和 IE6 中也是如此。 不是 但在 Firefox 2.0 中。令人费解。

How can I fix it?

到目前为止,唯一对我有用的解决方案是:

span {
    font-family: Courier; background-color: green;
}
span.b {
    font-weight: bold;
}

即指定 Courier 而不是等宽。这在我测试的所有浏览器(IE6、Opera 9、Windows 2000 下的 FF 2.0;Opera 10、FF 3 和 Ubuntu 下的 Konqueror)中呈现一致。至于为什么,我仍然不知道。

关于html - 为什么 bold monoface 在 Windows 上垂直移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2432328/

相关文章:

javascript - 响应式等高div不指定高度

PHP获取URL字符串参数?

javascript - 单击模态时如何在另一个选项卡中打开 URL

html - CSS/HTML 适合任何分辨率

移除上面的元素后,CSS3 将元素设置为动画或过渡

php - 使用 PHPUnit 进行单元和功能测试的文件系统/目录布局

Flutter:如何设置 PersistentFooterButtons 背景?

javascript - 拖放并定位到放置的坐标

iOS 动画 UITabBarController 滑动; View 重叠状态栏 - 仅在第一次加载时

html - 一个header的字体不会变,其他的会变,怎么办?