简体   繁体   English

在Rails 4中添加真棒字体的最简单方法是什么

[英]What's the easiest way to add font-awesome in rails 4

我已经按照http://fortawesome.github.io/Font-Awesome/get-started/上的字体真棒指南中的说明进行了操作,但是该字体没有出现在我的html.erb页面上,而是显示了奇怪的符号。

Personally I like the font-awesome-rails gem best. 我个人最喜欢font-awesome-rails gem。 It integrates FA into the asset pipeline and adds a fa_icon helper that you can use in your views. 它将FA集成到资产管道中,并添加了一个fa_icon帮助器,您可以在视图中使用它。

What code are you using for your classes? 您在课堂上使用什么代码? You need to use 'fa', not 'icon' eg 您需要使用“ fa”,而不是“ icon”,例如

class="fa fa-plus"

in your config/initializers/assets.rb add next strings: 在您的config/initializers/assets.rb添加下一个字符串:

Rails.application.config.assets.precompile += %w( fontawesome-webfont.eot )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.woff2 )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.woff )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.ttf )
Rails.application.config.assets.precompile += %w( fontawesome-webfont.svg )

in your app/assets/stylesheets/application.css add 在您的app/assets/stylesheets/application.css添加

*= require font-awesome

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

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