我已经在我的网站上添加了bootstrap。这是我正在使用的结构。(我无法删除bootstrap.css文件,因为我根据自己的喜好对其进行了修改)。
>app
>>assets
>>>fonts
>>>>4 glypicons icon files.
>>>images
>>>>N/A
>>>javascripts
>>>>Bootstrap.js (Jquery is installed in a gem)
>>>stylesheets
>>>>Bootstrap.css
一切都正确导入,但问题是字形图标不工作,我需要他们!
发布于 2013-11-30 14:55:21
2015年11月编辑:我推荐这个gem:https://github.com/twbs/bootstrap-sass,它由Bootstrap社区积极维护,与Ruby on Rails配合得非常好。
我遇到了一个和你非常相似的问题,但我想通了!在您的bootstrap.css文件中找到此部分:
@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');
}
并用/assets
替换../fonts/
。这就是你的最终代码的样子。
@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');
}
我希望这对你有帮助!
发布于 2014-07-03 21:42:44
如果您正在使用bootstrap-sass,并且遇到此问题,请尝试在您的某个scss文件中像这样导入bootstrap。如果你使用sass,只需转换语法:
@import "bootstrap-sprockets";
@import "bootstrap";
发布于 2013-11-28 08:50:29
我想你的asset pipeline可能有点问题
您想要将bootstrap.css
更改为bootstrap.css.scss
,然后替换它使用的位置
@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-path
(请参阅第2.3.2节- CSS和Sass)
@font-face {
font-family: 'Glyphicons Halflings';
src: font-path('glyphicons-halflings-regular.eot');
src: font-path('glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
font-path('glyphicons-halflings-regular.woff') format('woff'),
font-path('glyphicons-halflings-regular.ttf') format('truetype'),
font-path('glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
也在你的config/environments/production.rb
中
# Precompile additional assets
config.assets.precompile += %w( .svg .eot .woff .ttf )
在你的config/application.rb
中
# Add the fonts path
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
查看另一个SO post,了解类似的问题
希望这能有所帮助
https://stackoverflow.com/questions/20255711
复制相似问题