【发布时间】:2016-06-06 00:50:44
【问题描述】:
在此SO post 之后,我将所有@font-face 定义更改为如下所示:
@font-face {
font-family: 'Pe-icon-7-stroke';
src:font-url('/assets/Pe-icon-7-stroke.eot?d7yf1v');
src:font-url('/assets/Pe-icon-7-stroke.eot?#iefixd7yf1v') format('embedded-opentype'),
font-url('/assets/Pe-icon-7-stroke.woff?d7yf1v') format('woff'),
font-url('/assets/Pe-icon-7-stroke.ttf?d7yf1v') format('truetype'),
font-url('/assets/Pe-icon-7-stroke.svg?d7yf1v#Pe-icon-7-stroke') format('svg');
font-weight: normal;
font-style: normal;
}
所有字体文件都放在/assets/fonts/中。
我还将声明上述@font-face 的文件从.css 类型更改为.scss。字体仍在开发中加载,但是当我将更改添加到 git 并推送到我在 heroku 上的生产站点时,字体仍然没有加载。
这可能并不表示我遇到的问题,但是当我在实时站点上查看我的编译资产时,我看到对于字体的定义,写着:
font-family:'Pe-icon-7-stroke';
src:url(/assets/Pe-icon-7-stroke.eot?d7yf1v);
相对于font-url,它使用url(这可能是sass转换成css的方式,但也可能意味着旧的application.css正在加载?)
https://kaf.herokuapp.com/assets/application-490d8d687dc0c9b526bf1348ca9a3a6f.css
供参考,这是我在 Github 上的完整资产目录
【问题讨论】:
-
如果你的css和你的字体在同一个assets目录下你就不需要再调用/assets了,比如:"Pe-icon-7-stroke.eot" not "/assets /Pe-icon-7-stroke.eot”。无论如何,要上一个目录,您都需要使用“../directory above assets”。
标签: css ruby-on-rails heroku