首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bootstrap Glyphicons在Rails上不起作用

Bootstrap Glyphicons在Rails上不起作用
EN

Stack Overflow用户
提问于 2017-04-20 15:00:29
回答 1查看 1.5K关注 0票数 0

在我的Rails5应用程序中,我的application.sass文件中有这个...

代码语言:javascript
复制
/*
 *= require bootstrap-sass-official
 ...
 */

 @font-face
   font-family: 'Glyphicons Halflings'
   src: url('/assets/glyphicons-halflings-regular.eot')
   src: url('/assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('/assets/glyphicons-halflings-regular.woff') format('woff'), url('/assets/glyphicons-halflings-regular.ttf') format('truetype'), url('/assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg')

根据Ruby on Rails Bootstrap Glyphicons not working中的建议执行...as。我在Chrome控制台上看到这个错误:各种字体格式的Failed to decode downloaded font: http://localhost:3000/assets/glyphicons-halflings-regular.woffetc..

我是否需要将任何内容放到我的Rails assets fonts文件夹中?如果有,具体是什么?非常感谢你在这方面的帮助。

EN

回答 1

Stack Overflow用户

发布于 2017-04-20 15:35:17

由于应用程序是Rails5,更好的方法是将字体放在文件夹app/assets/fonts中。

如果你想把它们放在fonts文件夹之外,你需要添加以下配置:

config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/

然后可以使用您提到的url。

代码语言:javascript
复制
@font-face {
    font-family: 'Glyphicons Halflings';
    src: url('/assets/glyphicons-halflings-regular.eot');
    src: url('/assets/glyphicons-halflings-regular.eot?iefix') format('eot'),
         url('/assets/glyphicons-halflings-regular.woff') format('woff'),
         url('/assets/glyphicons-halflings-regular.ttf') format('truetype'),
         url('/assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43512394

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档