-2

我的问题是自定义字体在使用时不显示@font-face

我的 CSS 在它自己的文件中被引用,代码是:

@font-face {
    font-family: 'MerceariaAntique';
    src: url('type/mercearia_new/21319b_0_0-mercearia.eot');
    src: url('type/mercearia_new/21319b_0_0-mercearia.eot?#iefix') format('embedded-    opentype'),
         url('type/mercearia_new/21319b_0_0-mercearia.woff') format('woff'),
         url('type/mercearia_new/21319b_0_0-mercearia.ttf') format('truetype'),
         url('type/mercearia_new/21319b_0_0-mercearia.svg#webfontuploaded_file')     format('svg');
    font-weight: normal;
    font-style: normal;
    }

在我的 HTML 文件中,我在主 CSS 文件旁边将其引用为以下内容:

<link rel="stylesheet" type="text/css" media="all" href="css/fonts.css" />

我怀疑我错误地引用了它,但我不知道如何正确引用它。

4

2 回答 2

3

你的文件夹结构是什么?如果您在文件夹“css”中调用 css,则必须指出自定义字体的正确路径,例如“../”

src: url('../type/mercearia_new/21319b_0_0-mercearia.eot');
于 2012-09-06T19:55:18.660 回答
0

以下是如何使用@font-face 的示例:

@font-face {
  font-family: "Example Font";
  src: url("http://www.example.com/fonts/example");
}
h1 {
  font-family: "Example Font",  sans-serif;
}

我假设您已经检查了字体文件的路径并且它们是正确的。我还假设您已经检查了错误控制台是否有任何 CSS 警告或错误,例如找不到文件。

尝试仔细检查您在代码中将字体分配为 a的位置font-family

另外,font-face参考:http ://reference.sitepoint.com/css/at-fontface

更新:试试Google 的WebFont Loader

于 2012-09-06T19:50:14.507 回答