簡體   English   中英

Font Awesome字體無法加載?

[英]Font Awesome Fonts not loading?

我有一個Rails應用程序,為了管理我的資產,我使用Bower。 如果可能的話,我寧願不要對諸如JS和CSS之類的資產使用gem。

在我的vender/assets/stylesheets目錄中,我具有以下內容: font-awesome中有scssfonts

在我的rails 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中的source標簽,查看正在加載的內容,並在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目錄確實是一個目錄。

那么, 這是怎么回事?

我遇到了類似的問題,並通過使用以下css文件將其修復:

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

我不記得出了什么問題,只是希望能有所幫助。

作為記錄,這里的實際錯誤是您沒有分配“ fa”類。

代替:

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

你需要:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM