设置Font Awesome字体的方法很简单,只需将两行代码添加到你的网站。或者你可以成为一个专业和定制一个最简单的自己,Bootstrap 3 Font Awesome字体会让更好的扮演自己!
一、最简单的通过MaxCDN方法使用BootstrapCDN
由于在MaxCDN的慷慨的人,您可以使用BootstrapCDN字体的添加到你的网站一行代码。你甚至不需要下载和安装任何东西!
1.将下面的代码粘贴到你站点的HTML部分。
(后立即释放,需要一点时间BootstrapCDN赶上,得到最新的版本CDN生活。)2.拍拍自己的背你scalable-vector-icons-on-the-website柔道的解决方案在一行代码。
3.查看示例并开始使用Font Awesome字体!
二、简单的默认CSS样式
使用以下方式去获得默认的Font Awesome字体CSS
Copy the entire font-awesome directory into your project.
In the of your html, reference the location to your font-awesome.min.css.
Use the Official Font Awesome LESS Ruby Gem to easily get Font Awesome LESS into a Rails project. Generously maintained by @supercodepoet.
Add this line to your application’s Gemfile:
gem ‘font-awesome-less’
And then execute:
$ bundle
Or install it yourself as:
$ gem install font-awesome-less
If you use Rails, add this to your e.g. application.less:
@import “font-awesome-sprockets”;
@import “font-awesome”;
EASY: SASS Ruby Gem
Use the Official Font Awesome SASS Ruby Gem to easily get Font Awesome SASS into a Rails or Compass project. Generously maintained by @supercodepoet.
Add this line to your application’s Gemfile:
gem ‘font-awesome-sass’
And then execute:
$ bundle
Or install it yourself as:
$ gem install font-awesome-sass
If you use Rails, add this to your e.g. application.scss:
@import “font-awesome-sprockets”;
@import “font-awesome”;
PRO: Custom LESS or SASS
Use this method to customize Font Awesome 4.3.0 using LESS or SASS.
Copy the font-awesome/ directory into your project.
Open your project’s font-awesome/less/variables.less or font-awesome/scss/_variables.scss and edit the @fa-font-path or $fa-font-path variable to point to your font directory.
@fa-font-path: “…/font”;
The font path is relative from your compiled CSS directory.
Re-compile your LESS or SASS if using a static compiler. Otherwise, you should be good to go.
Check out the examples to start using Font Awesome!
Validators
In order to provide the best possible experience to old and buggy browsers, Font Awesome uses CSS browser hacks in several places to target special CSS to certain browser versions in order to work around bugs in the browsers themselves. These hacks understandably cause CSS validators to complain that they are invalid. In a couple places, we also use bleeding-edge CSS features that aren’t yet fully standardized, but these are used purely for progressive enhancement.
These validation warnings don’t matter in practice since the non-hacky portion of our CSS does fully validate and the hacky portions don’t interfere with the proper functioning of the non-hacky portion, hence why we deliberately ignore these particular warnings.
Need IE7 Support?
If you need IE7 support, you have my condolences. Really. Font Awesome 4.3.0 doesn’t support IE7, but an older version does. You’ll need to check out the 3.2.1 instructions for using IE7. Then go complain to whomever decided your project needs IE7 support.
Troubleshooting
If you’re having trouble with Font Awesome, make sure to check out the troubleshooting wiki page. Generously maintained by @gtagliala.