【问题标题】:Relative paths not valid for embedding fonts with CSS?相对路径对于使用 CSS 嵌入字体无效?
【发布时间】:2015-07-10 01:47:00
【问题描述】:

我正在尝试嵌入字体,就像我对 FontSquirrel 生成的 CSS 所做的那样,只是使用相对路径:

@font-face {
    font-family: 'MyFontFamily';
    src: url('config/templates/fonts/MyFont.eot');
    src: url('config/templates/fonts/MyFont.eot?#iefix') format('embedded-opentype'),
     url('config/templates/fonts/MyFont.woff') format('woff'),
     url('config/templates/fonts/MyFont.ttf') format('truetype'),
     url('config/templates/fonts/MyFont.svg#MyFont') format('svg');
    font-weight: normal;
    font-style: normal;
}

这似乎不起作用。

将其更改为/base/config/templates/fonts... 可以解决问题,但为了应用程序,最好使用相对路径。

字体文件确实相对于使用它们的文档存在。

字体导入的相对路径是不可接受的吗?这是怎么回事?

【问题讨论】:

    标签: html css fonts


    【解决方案1】:

    改成:

    ./config/templates/fonts/...
    

    或者在某些情况下:

    ../config/templates/fonts/...
    

    取决于您的结构。

    【讨论】:

    • 怎么样:/../config/templates/fonts/
    猜你喜欢
    • 2023-03-20
    • 2020-08-09
    • 2023-04-05
    • 1970-01-01
    • 2018-03-08
    • 2015-09-20
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多