如何向网站添加字体 [英] How to Add Fonts to a Website

查看:111
本文介绍了如何向网站添加字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要将字体添加到网站。

Want to add a font to website.

CSS文件:

@font-face {
    font-family: smFont;
    src: url(optima-regular-webfont.woff);

}

.smFont {
    font-family: smFont;
}

HTML档案:

关于< strong class =smFont>公司< / strong>

上面但是字体不出来了。
我的代码错了吗?

I have the above but the font doesn't come out right. Is my code wrong?

推荐答案

确保你的路径是正确的,如果你看看控制台,当你访问您的网站可以看到对字体文件的失败请求。

Make sure your path is correct, if you look at the console when you visit your website you can see failed requests to the font files.

目前,当他们在父目录中时,它们的目标是/ css /目录。因此,只需将CSS更改为以下内容即可解决此问题。

It's currently targeting the /css/ directory for them when they are in the parent directory. So simply changing the CSS to the following should resolve the issue.

@font-face {
    font-family: smFont;
    src: url("../optima-regular-webfont.woff");
}

这篇关于如何向网站添加字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆