字体真棒字体没有加载?

时间:2014-07-16 18:24:25

标签: html css ruby-on-rails fonts font-awesome

我有一个rails应用程序,并且管理我的资产我使用的是凉亭。如果可能的话,我更愿意不将gems用于JS和CSS等资产。

在我的vender/assets/stylesheets目录中,我有以下内容:font-awesome位于scssfonts

在我的导轨中app/assets/stylesheets/application.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 .
 *= require style.scss
 *= require chosen/chosen.min
 *= require jquery.ui.all
 *= require selectize.js/css/selectize.css
 *= require selectize.js/css/selectize.bootstrap3.css
 *= require font-awesome/scss/font-awesome
 */

页面加载正常。但是当我这样做时:<i class="fa-question></i>而不是得到问号我得到[]。所以我检查了chrome中的sources选项卡以查看正在加载的内容,并在font-awesome目录下只有font-awesome.scss,在查看后我看到:

/*!
 *  Font Awesome 4.1.0 by @davegandy - http://fontawesome.io - @fontawesome
 *  License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
 */

@import "variables";
@import "mixins";
@import "path";
@import "core";
@import "larger";
@import "fixed-width";
@import "list";
@import "bordered-pulled";
@import "spinning";
@import "rotated-flipped";
@import "stacked";
@import "icons";

所以我有信心说这是加载css,但字体没有被加载。所以我查看了变量,其中将定义字体路径,并参见:

$fa-font-path:        "../fonts" !default;

根据上面列出的目录结构,fonts目录确实是一个目录。

那么,发生了什么?

2 个答案:

答案 0 :(得分:2)

我遇到了类似的问题并使用以下css文件修复了它:

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">

我无法回想起出了什么问题,只希望这会有所帮助。

答案 1 :(得分:2)

对于记录,此处的实际错误是您未分配&#34; fa&#34;类。

而不是:

<i class="fa-question"></i>

你需要:

<i class="fa fa-question"></i>