【发布时间】:2012-09-25 21:33:24
【问题描述】:
我的 CSS 文件和字体文件都在主域下,比如说在
http://www.mydomain.com/css 和 http://www.mydomain.com/fonts
我在一些子域上也有文件,这些文件需要共享 css 和字体 主域文件的样式。因此,我只是在我的文件顶部:
<link rel="stylesheet" type="text/css" href="http://www.mydomain.com/css/algemeen.css" media="all" />
<link rel="stylesheet" type="text/css" href="http://www.mydomain.com/css/gemeenten.css" media="all" />
<link rel="stylesheet" type="text/css" href="http://www.mydomain.com/css/sidebars.css" media="all" />
一切都很好,CSS 显示得很好。但是,在这些 CSS 文件中,我使用了@font-face。此代码本身在所有浏览器中都可以正常工作,至少对于主域上的文件是这样。所以http://www.mydomain.com/index.php 在所有浏览器中完美地显示了我选择的字体。但是,我的子域上使用相同 CSS 的 index.php 没有在 IE 或 Firefox 中显示我选择的字体!它只使用标准的 Arial。 Safari、Opera 和 Chrome 运行良好。这怎么可能?我的@font-face 代码:
@font-face {
font-family: "Nova"; font-weight: normal;
font-style: normal;
src: url("../fonts/proximanova-regular.eot");
}
@font-face {
font-family: "Nova";
src: url("../fonts/proximanova-semibold.eot");
font-weight: 900;
}
@font-face {
font-family: "Nova"; font-weight: normal;
font-style: normal;
src: url("../fonts/proximanova-regular.ttf") format("truetype");
}
@font-face {
font-family: "Nova";
src: url("../fonts/proximanova-semibold.ttf") format("truetype");
font-weight: 900;
}
谢谢大家!
已经在字体文件夹中添加了带有此代码的 .htaccess:
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
【问题讨论】: