简体   繁体   English

Font-Awesome-Rails无法加载图标

[英]Font-Awesome-Rails Not Loading Icons

I have this in my Gemfile : 我的Gemfile有这个:

gem 'rails', '4.1.0'
gem "therubyracer"
gem 'jquery-rails'
gem 'bootstrap-sass'
gem 'sass-rails', '4.0.2'
gem 'autoprefixer-rails'
gem 'simple_form', '~> 3.1.0.rc1'
gem 'devise'
gem 'geocoder'
gem 'paperclip', '~> 4.1'
gem 'font-awesome-rails'

I've included this in app/assets/stylesheets/application.css.scss 我已将其包含在app/assets/stylesheets/application.css.scss

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
 */
@import "font-awesome";
@import "bootstrap-sprockets";
@import "bootstrap";

I've then put this in my view: 然后,我将其视为:

          <%= fa_icon "camera-retro" %>

In my browser, I can see the HTML rendered as such: 在我的浏览器中,我可以看到这样渲染的HTML:

<i class="fa fa-camera-retro"></i>

However, no icon displays. 但是,没有图标显示。

I can also see font-awesome.css is loading here: 我还可以看到font-awesome.css在这里加载:

在此处输入图片说明

When I do: 当我做:

          <%= fa_icon "camera-retro", text: "hello there camera" %>

I get: 我得到:

在此处输入图片说明

Here's me adding text to the helper: 这是我向助手添加文本:

I'm sure I've missed something but what? 我确定我错过了什么,但是呢?

I had a hard copy of the font-awesome.css in my app/assets/stylesheets directory that was causing the issue. 我的app / assets / stylesheets目录中有font-awesome.css的硬拷贝,这是造成此问题的原因。 I removed that and the gem worked as expected! 我删除了该宝石,宝石按预期工作!

That is a bug . 那是一个错误

Try to use 尝试使用

@import "font-awesome.css";

instead of 代替

@import "font-awesome";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM