gpt4 book ai didi

html - 有没有办法解决 IE10&9 更宽的字体渲染差异?

转载 作者:行者123 更新时间:2023-11-28 01:49:36 25 4
gpt4 key购买 nike

我在使用 IE10 和 9 字体呈现 arial 时遇到问题;
在 IE7、8、Chrome、FF 上,它就像我在 Dreamweaver 上看到的一样,
但是 IE10 和 9 字体变得更宽,使我的文本跳到一个额外的行。

Reset.css 或 normalize.css 都没有帮助。

截图:

enter image description here

这是我的代码:

<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
background-color: gray;
margin-bottom: 0px;
font-style: normal;
font-weight: 300;
}

#container {
border: 1px solid #DCD7D4;
width: 768px;
min-height: 400px;
position: relative;
margin-left: auto;
margin-right: auto;
margin-top: 8px;
}
#left {
float: left;
width: 580px;
min-height: 400px;
background-color: #FBFBFB;
color: #565656;
}

#margin {
margin-bottom: 6px;
margin-left: 18px;
margin-right: 6px;
margin-top: 11px;
}

.text {
font-size: 15px;
color: #565656;
font-weight: 400;
line-height: 21px;
margin-top: 0px;
margin-bottom: 2px;
}

-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

<body>

<div id="container">
<div id="left">
<div id="margin">
<p class="text">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<br>
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<br>
AAAA AAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA aaa aaaaaaaa</p>
</div>
</div>

<br style="clear: left;" />
</div>


</body>

Here's the jsfiidle

谢谢

最佳答案

您的屏幕截图之间的差异实际上来自所讨论浏览器之间字体渲染的差异。下面是在 Win7 上的 Chrome 和 IE9 中你的 fiddle 中的 A 字母的放大截图(在添加 letter-spacing: 0; 之后)。

enter image description here

如您所见,即使是相同的字体 (Arial)、font-sizefont-weightletter-spacing在这两种情况下,IE9 都会将字母渲染得更宽一些,从而使行/单词更长。

IE9 使用 DirectWrite 模式/技术来呈现字体,这与 IE6-8 使用的 GDI 模式相反,Windows 机器上的 Chrome、Opera(有时还有 Firefox)(source)。这解释了为什么 IE9(及更高版本)呈现的字体与 Windows 上的其他浏览器不同。

根据上面的同一篇文章:

DirectWrite not only gives smoother outlines, it also applies subpixel rendering to PostScript fonts. Unlike TrueType rendering, however, it allows for more gray pixels in order to reflect stroke weights more realistically. That makes it well-balanced, and similar to Mac OS rendering.

DirectWrite 字体渲染与 Mac OS 字体渲染相似(但不同),这可能解释了为什么我在 OSX 上的 Chrome 和 Firefox 中获得的结果与您在 IE9 中获得的结果相似。

更新:您可以尝试的一件事是尝试使用不同的网络字体。 In this example ,我使用了 Source Sans Pro(Google 字体),您可以看到 IE9 和 Chrome 之间的渲染差异不太明显。

关于html - 有没有办法解决 IE10&9 更宽的字体渲染差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20806854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com