@font-face 中的 CSS 相对路径

标签 css font-face relative-path

在 Firefox、Chrome、IE 中测试

-index.html
    -foo
      |-my.css
      |-bar.jpg
      |-qux.ttf
      |- ...

这是有效的(绝对路径)

div.class {background: url(http://www.foobar.com/foo/bar.jpg);}

这是有效的(相对路径)

div.class {background: url(bar.jpg);}

这是有效的(绝对路径)

p.class {font-family: 'qux'; src: url(http://www.foobar.com/foo/qux.ttf) format('ttf');}

=> 这 工作(相对路径)

p.class {font-family: 'qux'; src: url(qux.ttf) format('ttf');}

适用于background,但不适用于@font-face

感谢您的帮助。 :)

最佳答案

问题的解决方案是编辑 browserSync 设置 (baseDir)。

谢谢

关于@font-face 中的 CSS 相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35973817/

相关文章:

javascript - 悬停文本链接时显示图像?

css - 我怎么知道是否允许在@font-face 中使用任何字体?

css - @font-face 在本地工作,但不能在实时网站上工作

django - django settings.py 中的相对路径

c# - 相对路径 Visual Studio

css - 如何仅使用 CSS 创建响应式设计

html - 全宽重叠三 Angular 形

node.js - 通过 LESS 在 Twitter Bootstrap 中集成 Font Squirrel 生成的字体

c++ - 使用 fopen 打开文件,在 Windows 上给定绝对路径

html - 如何使用 CSS 自动将 » (») 添加到 <li> 元素?