【发布时间】:2014-06-09 17:32:41
【问题描述】:
我正在尝试在 Rails 4 中使用自定义字体。这是我的 CSS 中的内容:
@font-face {
font-family: 'bebas';
src: url('<%= asset_path 'bebasneue-webfont.eot' %>');
src: url('<%= asset_path 'bebasneue-webfont.eot?#iefix' %>') format('embedded-opentype'),
url('<%= asset_path 'bebasneue-webfont.woff' %>') format('woff'),
url('<%= asset_path 'bebasneue-webfont.ttf' %>') format('truetype'),
url('<%= asset_path 'bebasneue-webfont.svg#bebas_neueregular' %>') format('svg');
font-weight: normal;
font-style: normal;
}
我将字体文件添加到app/assets/fonts:
bebasneue-webfont-069a8fc829e693fcf470f2352359e221.woff
bebasneue-webfont-56194c50f0b197ee12f067a502a17b30.svg
bebasneue-webfont-755b9b8c0760ef96285f451dca15e4ba.eot
bebasneue-webfont-7d82d863523d9e753d1e51e240a48b6f.ttf
在config/application.rb我添加了以下内容:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
然后我在我的 CSS 标记中简单地引用它:
.lineup .table .logos .price {
text-transform: uppercase;
font-family: 'bebas', sans-serif;
}
这似乎不起作用。有什么明显的缺失吗?
【问题讨论】:
标签: css ruby-on-rails ruby-on-rails-4 fonts