我知道stackoverflow充满了这些问题,但我找到的解决方案并没有解决我的问题,首先,所有的响应似乎都假设你已经安装了一些gem来使用bootstrap (像bootstrap-sass),而我唯一做的就是下载它并将内容放在适当的文件夹中,如here所解释的那样。
因此,一半的答案是将这些命令放入:
@import "bootstrap-sprockets"
@import "bootstrap"在我的scss或sass文件中(我没有)。
另一半说我必须改变这一点:
@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');
}为此:
@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');
}对我不起作用。
那么,谁有其他的解决方案呢?
发布于 2016-01-17 17:41:56
,所以一半的答案是把这些命令
#app/assets/stylesheets/application.sass
@import bootstrap这将在您的主application.sass文件中包含bootstrap.sass文件,允许您从中引用类等。
这与任何字体问题等无关。你最好在sprockets manifest directives上阅读,了解更多关于它是如何工作的信息。
字体
对于你的字体问题,你有几个问题。
bootstrap gem我强烈建议使用rails-assets直接从bootstrap repo中拉出(保持整洁):
#Gemfile
source "https://rails-assets.org"
gem 'rails-assets-bootstrap', ">= 4.0.0.alpha.2" 这将在您的系统上放置所有适当的bootstrap文件,然后您将能够通过您的资产管道引用这些文件:
#app/assets/stylesheets/application.sass
@import bootstrap这应该包括你所有的字体。
为了确保它们能正常工作,您最好为生产模式预编译资产:
$ rake assets:precompile RAILS_ENV=productionhttps://stackoverflow.com/questions/34836120
复制相似问题