@ font-face css添加自定义字体

时间:2017-01-16 13:29:47

标签: css wordpress fonts font-face

我有一个wordpress主题,我想添加一个自定义字体。我在主题文件中添加了一个“fonts”文件夹,我在其中放置了字体文件。

现在我的css看起来像这样:

@font-face {
font-family: Brandon;
src: url('/domains/test.innerwhy.com/html/wp-content/themes/thefox/fonts/Brandon_bld.otf');
font-weight: normal;
}
h1 {
font-family: Brandon;
}

然而,这似乎不起作用,我不明白为什么。

2 个答案:

答案 0 :(得分:1)

通过查看我只能建议您从css文件中检查路径是否正确。如果字体无法加载也可以设置回退。您可能还缺少设备支持的字体文件类型。




答案 1 :(得分:0)

由于src路径错误,它无效。 “/domains/test.innerwhy.com/html/wp-content/themes/thefox/fonts/Brandon_bld.otf”

您可以在本地下载字体文件并使用如下:

@font-face {
font-family: 'Montserrat-Regular';
src: url('../fonts/montserrat-regular-webfont.eot');
src: url('../fonts/montserrat-regular-webfont.eot?#iefix') format('embedded-opentype'),
     url('../fonts/montserrat-regular-webfont.woff2') format('woff2'),
     url('../fonts/montserrat-regular-webfont.woff') format('woff'),
     url('../fonts/montserrat-regular-webfont.ttf') format('truetype');

}