简体   繁体   English

CSS:字体家族样式的优先级

[英]CSS: precedence of font-family style

see this snippet 看到这个片段

<span style="font-family: 'Helvetica Neue';">Storico settimanale</span><BR>
<span style="font-family: 'Helvetica';">Storico settimanale</span><BR>
<span style="font-family: 'Helvetica Neue', Helvetica;">Storico settimanale</span><BR>

I know ( see here ) that browser MUST try to use the first font, if not found try the second, and go on. 我知道( 请参阅此处 )浏览器必须尝试使用​​第一种字体,如果找不到,请尝试使用第二种字体,然后继续。

But in FF * versions and IE 11 I got this: 但是在FF *版本和IE 11中,我得到了:

在此处输入图片说明

I supposed to see Helvetica Neue on first and on third line, and Helvetica on the second. 我应该在第一行和第三行看到Helvetica Neue,在第二行看到Helvetica。

Why I got Helvetica in the third line? 为什么我在第三行得到Helvetica?

Helvetica Neue is a sans-serif font. Helvetica Neue是一种无衬线字体。 The image shows a serif font on the first line. 该图像在第一行显示衬线字体。 This means that the font you get on the first line is not Helvetica Neue. 这意味着您在第一行获得的字体不是 Helvetica Neue。 Your browser cannot find Helvetica Neue so it uses the default fallback font for when none of the fonts in the font-family list are available. 您的浏览器找不到Helvetica Neue,因此在font-family列表中没有可用字体时,它将使用默认的后备字体。

You get Helvetica on the third line because Helvetica Neue is not available but Helvetica is. 您会在第三行看到Helvetica,因为Helvetica Neue不可用,而Helvetica是可用的。

The fact that you get the standard serif font in the first <span> , and Helvetica in the last <span> , I'd take a punt say that you don't have Helvetica Neue installed on your machine. 实际上,您在第一个<span>获得标准衬线字体,而在最后一个<span>中获得Helvetica,事实上,我要说的是您的计算机上未安装Helvetica Neue。

Don't forget that the local machine should have the fonts installed, that's why you specify a font-face order. 不要忘记本地计算机应该安装字体,这就是为什么要指定字体顺序的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM