首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >某些Glyphicons不起作用

某些Glyphicons不起作用
EN

Stack Overflow用户
提问于 2016-01-17 15:25:38
回答 1查看 192关注 0票数 0

我知道stackoverflow充满了这些问题,但我找到的解决方案并没有解决我的问题,首先,所有的响应似乎都假设你已经安装了一些gem来使用bootstrap (像bootstrap-sass),而我唯一做的就是下载它并将内容放在适当的文件夹中,如here所解释的那样。

因此,一半的答案是将这些命令放入:

代码语言:javascript
复制
@import "bootstrap-sprockets"
@import "bootstrap"

在我的scss或sass文件中(我没有)。

另一半说我必须改变这一点:

代码语言:javascript
复制
@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

为此:

代码语言:javascript
复制
@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('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

对我不起作用。

那么,谁有其他的解决方案呢?

EN

回答 1

Stack Overflow用户

发布于 2016-01-17 17:41:56

,所以一半的答案是把这些命令

代码语言:javascript
复制
#app/assets/stylesheets/application.sass
@import bootstrap

这将在您的主application.sass文件中包含bootstrap.sass文件,允许您从中引用类等。

这与任何字体问题等无关。你最好在sprockets manifest directives上阅读,了解更多关于它是如何工作的信息。

字体

对于你的字体问题,你有几个问题。

  1. 您只需要一个bootstrap gem
  2. 您不需要手动将其文件包含在任何位置(它们包含在gem中)

我强烈建议使用rails-assets直接从bootstrap repo中拉出(保持整洁):

代码语言:javascript
复制
#Gemfile
source "https://rails-assets.org"

gem 'rails-assets-bootstrap', ">= 4.0.0.alpha.2" 

这将在您的系统上放置所有适当的bootstrap文件,然后您将能够通过您的资产管道引用这些文件:

代码语言:javascript
复制
#app/assets/stylesheets/application.sass
@import bootstrap

这应该包括你所有的字体。

为了确保它们能正常工作,您最好为生产模式预编译资产:

代码语言:javascript
复制
$ rake assets:precompile RAILS_ENV=production
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34836120

复制
相关文章

相似问题

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