【发布时间】:2011-02-20 20:09:28
【问题描述】:
以下代码适用于 Google Chrome beta 和 IE 7。但是,Firefox 似乎对此有问题。我怀疑这是如何包含我的 CSS 文件的问题,因为我知道 Firefox 对跨域导入不太友好。
但这都是静态 HTML,不存在跨域问题。
在我的landing-page.html 上,我像这样进行 CSS 导入:
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen, projection" />
在 main.css 中我有另一个像这样的导入:
@import url("reset.css");
@import url("style.css");
@import url("type.css");
在 type.css 中我有以下声明:
@font-face {
font-family: "DroidSerif Regular";
src: url("font/droidserif-regular-webfont.eot");
src: local("DroidSerif Regular"),
url("font/droidserif-regular-webfont.woff") format("woff"),
url("font/droidserif-regular-webfont.ttf") format("truetype"),
url("font/droidserif-regular-webfont.svg#webfontpB9xBi8Q") format("svg");
font-weight: normal; font-style: normal; }
@font-face {
font-family: "DroidSerif Bold";
src: url("font/droidserif-bold-webfont.eot");
src: local("DroidSerif Bold"),
url("font/droidserif-bold-webfont.woff") format("woff"),
url("font/droidserif-bold-webfont.ttf") format("truetype"),
url("font/droidserif-bold-webfont.svg#webfontpB9xBi8Q") format("svg");
font-weight: normal; font-style: normal; }
body { font-family: "DroidSerif Regular", serif; }
h1 { font-weight: bold; font-family: "DroidSerif Bold", serif; }
我在 type.css 所在的位置有一个名为“font”的目录。此字体目录包含所有 woff/ttf/svg 文件等。
我被这个难住了。 它适用于 Chrome 和 IE,但不适用于 Firefox。这怎么可能?我错过了什么?
【问题讨论】:
-
我现在遇到了 FontSquirrel 生成的指令和字体的确切问题。
-
出于测试目的,您可以尝试将@font-face 声明添加到您的html 之间的
<style>标记之间,看看您是否有同样的问题? -
添加一个逗号也可以解决这个问题,比如:url('Sans-serif') format('woff')
标签: css firefox font-face file-uri