@ font-face src可以使用相对路径吗? [英] Can relative paths be used for @font-face src?

查看:2475
本文介绍了@ font-face src可以使用相对路径吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CSS中使用 @ font-face 使用自定义字体时,我可以为字体指定相对路径。说我有以下结构:

  WebContent 
- css
| - style01.css
| - style02.css
| - ...
- fonts
| - font01.ttf
| - font01.ttf
| - ...
- 图片
| - ...
- js
| - ...
- index.html
- * .html

我可以指定类似的:

  @ font-face {
font-family:'font one';
src:url('../ fonts / font01.ttf');
}

,因为上面似乎不起作用。

解决方案

看起来问题是它不喜欢单引号' / p>

When using @font-face in CSS to use custom fonts, can I specify a relative path for the fonts. Say I have the following structure:

WebContent
 - css
    |- style01.css
    |- style02.css
    |- ...
 - fonts
    |- font01.ttf
    |- font01.ttf
    |- ...
 - images
    |- ...
 - js
    |- ...
 - index.html
 - *.html

Can I specify something similar to:

@font-face {
   font-family: 'font one';
   src: url('../fonts/font01.ttf');
}

since the above does not seem to work.

解决方案

Seems the issue was that it doesn't like the single quotes ' around the name.

这篇关于@ font-face src可以使用相对路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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