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

前端之家收集整理的这篇文章主要介绍了css – 为什么IE9 / Firefox与其他浏览器显示不同的字体大小?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在编程网站的CSS,并意识到Internet Explorer 9与其他浏览器(Firefox,Chrome,Safari,IE7和IE8)相比,显示不同的字体大小.

我已经尝试使用一些RESETS,我以px指定字体,但IE9仍然显示字体大小的差异.

我试过在pt,in,percent中使用font-size,但没有成功.

之前我改变了字体(格鲁吉亚,Times New Roman,Verdana).其中一些显示较大,其他则在IE9中较小.

我在IE中检查了缩放设置和文字大小.分别为100%和中等.

为了说明,我创建了一个简单的HTML和CSS,你可以看到下面的代码.如何解决这个问题?谢谢!

问题:

码:

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,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使用 DirectWrite渲染文本,其他浏览器(Firefox 4除外).

这就是两个浏览器之间的文本大小稍微不同的原因.

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

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

而且,特别是“提示和间距差异”部分:http://blog.mozilla.com/nattokirai/2011/08/11/directwrite-text-rendering-in-firefox-6/

原文链接:https://www.f2er.com/css/216354.html

猜你在找的CSS相关文章