twitter-bootstrap-rails on Heroku: Glyphicons displayed as squares

回眸只為那壹抹淺笑 提交于 2019-12-02 21:27:37

Fixed it. The CSS that was causing the problem:

[class^="icon-"], [class*=" icon-"] {
display: inline;
width: auto;
height: auto;
line-height: inherit;
vertical-align: baseline;
background-image: none;
background-position: 0% 0%;
background-repeat: repeat;

was part of Fontawesome, which is included by default in twitter-bootstrap-rails. The issue was that the Fontawesome icon files were not being precompiled, because they are unusual filetypes. I went into the production.rb environment file, and added '.woff', '.eot', '.svg', '.ttf' to the config.assets.precompile list. I then re-compiled my assets, and the icons showed up! Boom.

I solved this problem by adding to config/environments/production.rb:

config.assets.precompile += %w( '.woff', '.eot', '.svg', '.ttf' )

Also I have next string in Gemfile, without github path:

gem 'twitter-bootstrap-rails'

With this configuration Glyphicons displayed well on Heroku.

Make these changes in your bootstrap.css file:

somewhere around line 1174:

-  background-image: url("../img/glyphicons-halflings.png");
+  background-image: image-url("glyphicons-halflings.png");

and somewhere around line 1183:

-  background-image: url("../img/glyphicons-halflings-white.png");
+  background-image: image-url("glyphicons-halflings-white.png");

I think that'll do the trick.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!