为什么 IE9/Firefox 显示的字体大小与其他浏览器不同?

2023-12-19

我正在对一个网站的 CSS 进行编程,并意识到 Internet Explorer 9 显示的字体大小与其他浏览器(Firefox、Chrome、Safari、IE7 和 IE8)不同。

我尝试过使用一些重置,并且我在中指定字体px,但IE9仍然显示字体大小的差异。

我尝试过使用font-size in pt, in,百分比,但没有成功。

我之前更改过字体(Georgia、Times New Roman、Verdana)。其中一些在 IE9 中显示得更大,另一些则更小。

我检查了 IE 中的缩放设置和文本大小。它们分别是 100% 和中等。

为了说明这一点,我创建了一个简单的 HTML 和 CSS,如下面的代码所示。如何解决这个问题呢?谢谢!

问题:

Code:

HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>Untitled Document</title>
</head>
<body>
    <p>
    AAAAA BBBBB CCCCC DDDDD EEEEE FFFFF GGGGG HHHHH IIIII JJJJJ KKKKK LLLLL MMMMM NNNNNN OOOOO PPPPP QQQQQ
    </p>
</body>
</html>

CSS

/* RESET */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}

/* END OF RESET */

body {
    background-image:url(GreenLine.png);
    background-repeat:no-repeat;
    font-family:"Courier New", Courier, monospace;
    font-size:12px;
}

IE9使用直接写入 http://en.wikipedia.org/wiki/DirectWrite渲染文本,而其他浏览器则不渲染(Firefox 4+ 除外)。

这就是两个浏览器之间的文本大小略有不同的原因。

没有办法使文本大小相同。

读这个:http://www.basschouten.com/blog1.php/font-rendering-gdi-versus-directwrite http://www.basschouten.com/blog1.php/font-rendering-gdi-versus-directwrite

和这个,特别“狩猎和间距差异”部分:https://web.archive.org/web/20120603023828/https://blog.mozilla.org/nattokirai/2011/08/11/directwrite-text-rendering-in-firefox-6/ https://web.archive.org/web/20120603023828/https://blog.mozilla.org/nattokirai/2011/08/11/directwrite-text-rendering-in-firefox-6/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么 IE9/Firefox 显示的字体大小与其他浏览器不同? 的相关文章