http://www.bootcss.com/p/font-awesome/

將Font Awesome 集成到 Bootstrap 很是容易,還能夠被單獨使用。css

最簡單的 Bootstrap + Font Awesome 集成方式

使用這種方式將 Font Awesome 集成到默認的 Bootstrap CSS中。html

  1. 拷貝 Font Awesome 字體目錄到你的項目中。
  2. font-awesome.min.css 文件到你的項目中。
  3. 打開你的項目中的 font-awesome.min.css 文件並編輯字體路徑指向正確的位置。

    字體路徑是相對於你的 CSS 目錄的。git

  4. 在html文檔中的 <head> 部分,引入 font-awesome.min.css 文件。
    1. <link rel="stylesheet" href="../css/bootstrap.min.css">
    2. <link rel="stylesheet" href="../css/font-awesome.min.css">
  5. 在瀏覽器中打開頁面,檢查是否正確啓用了 Font Awesome!

自定義 Bootstrap + Font Awesome LESS文件的方式進行集成

修改Bootstrap的LESS文件以集成 Font Awesome。github

  1. 拷貝 Font Awesome 字體目錄到你的項目中。
  2. 拷貝 font-awesome.less 文件到 bootstrap/less 目錄。
  3. 打開 bootstrap.less 文件,並將 @import "sprites.less"; 替換爲 @import "font-awesome.less";
  4. 打開你的項目中的 font-awesome.less 文件,並編輯 @FontAwesomePath 變量,將其值替換爲指向字體文件的正確路徑。
    1. @FontAwesomePath: "../font";

    字體路徑相對於存放編譯以後的CSS文件的目錄。bootstrap

  5. 從新編譯Bootstrap的全部 LESS 文件。若是你使用的是less.js腳本動態編譯的話就能直接在瀏覽器中看到效果了。
  6. 在瀏覽器中打開頁面,檢查是否正確啓用了 Font Awesome!

自定義 Bootstrap + Font Awesome 集成,並使用 SASS 或 SCSS

我也從未使用過SASS或SCSS,若是源碼包中的SCSS或SASS文件有問題的話請通知我。瀏覽器

不使用 Bootstrap?

Font Awesome works just as well without Twitter Bootstrap.app

  1. Copy the Font Awesome font directory into your project.
  2. Copy font-awesome.less or font-awesome.min.css into your project.
  3. Open your project's font-awesome.less or font-awesome.min.css and edit the font location to point it to your font directory (see above examples).
  4. Check out the examples to start using Font Awesome!

須要支持 IE7 瀏覽器?

Font Awesome supports IE7. If you need it, you have my condolences.less

  1. Get Font Awesome working properly in a modern browser.
  2. Copy font-awesome-ie7.min.css into your project.
  3. In the <head> of your html, reference the location to your font-awesome-ie7.min.css.
    1. <link rel="stylesheet" href="../css/bootstrap.min.css">
    2. <link rel="stylesheet" href="../css/font-awesome.min.css">
    3. <!--[if IE 7]>
    4. <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css">
    5. <![endif]-->
  4. Go complain to whoever decided your project needs IE7 support.

下面的案例大部分都是重用 Bootstrap 文檔中的案例。ide

Use Font Awesome icons in:字體

  • Bulleted lists (like this one)
  • Buttons
  • Button groups
  • Navigation
  • Prepended form inputs
  • And many more with Custom CSS
 
 
Use a few of the new styles together, and you've got easy pull quotes or a great introductory article image. Or spinning icons for loading and refreshing content. Or fun big icons in multi-line buttons. Lots of new possibilities.
Spinner icon when loading content...

Inline Icons

Place Font Awesome icons just about anywhere with the <i> tag.

icon-camera-retro
  1. <i class="icon-camera-retro"></i> icon-camera-retro
Icon classes are echoed via CSS :before.

更大的圖標

經過給圖標設置 icon-largeicon-2xicon-3xicon-4x 樣式,能夠讓圖標相對於它所在的容器變得更大。

經過應用 icon-large (增大 33%), icon-2x, icon-3xicon-4x 樣式讓圖標變得更大。

icon-camera-retro

icon-camera-retro

icon-camera-retro

icon-camera-retro

  1. <p><i class="icon-camera-retro icon-large"></i> icon-camera-retro</p>
  2. <p><i class="icon-camera-retro icon-2x"></i> icon-camera-retro</p>
  3. <p><i class="icon-camera-retro icon-3x"></i> icon-camera-retro</p>
  4. <p><i class="icon-camera-retro icon-4x"></i> icon-camera-retro</p>
If your icons are getting chopped off on top and bottom, make sure you have sufficient line-height.

Animated Spinner

Use the icon-spin class to get any icon to rotate. Works best with icon-spinner and icon-refresh.

Spinner icon when loading content...
  1. <i class="icon-spinner icon-spin"></i> Spinner icon when loading content...

CSS3 animations aren't supported in IE7 - IE9.

 

Bordered & Pulled Icons

Use icon-border and pull-right or pull-left for easy pull quotes or article graphics.

Use a few of the new styles together, and you've got easy pull quotes or a great introductory article image. Or spinning icons for loading and refreshing content. Or fun big icons in multi-line buttons. You can combine all of them in any combination to get lots of new possibilities.
  1. <i class="icon-quote-left icon-4x pull-left icon-muted"></i>
  2. Use a few of the new styles together ... lots of new possibilities.
Use a few of the new styles together, and you've got easy pull quotes or a great introductory article image. Or spinning icons for loading and refreshing content. Or fun big icons in multi-line buttons. You can combine all of them in any combination to get lots of new possibilities.
  1. <i class="icon-flag icon-4x pull-left icon-border"></i>
  2. Use a few of the new styles together ... lots of new possibilities.

按鈕

Font Awesome 圖標可以很好的應用於按鈕組件中。將圖標設置的再大也能夠,Bootstrap中的 pull-rightpull-lefticon-spin 樣式均可以應用到圖標上。

  1. <a class="btn" href="#">
  2. <i class="icon-repeat"></i> Reload</a>
  3. <a class="btn btn-success" href="#">
  4. <i class="icon-shopping-cart icon-large"></i> Checkout</a>
  5. <a class="btn btn-large btn-primary" href="#">
  6. <i class="icon-comment"></i> Comment</a>
  7. <a class="btn btn-small btn-info" href="#">
  8. <i class="icon-info-sign"></i> Info</a>
  9. <a class="btn btn-danger" href="#">
  10. <i class="icon-trash icon-large"></i> Delete</a>
  11. <a class="btn btn-small" href="#">
  12. <i class="icon-cog"></i> Settings</a>
  13. <a class="btn btn-large btn-danger" href="#">
  14. <i class="icon-flag icon-2x pull-left"></i>Font Awesome<br>Version 3.0</a>
  15. <a class="btn btn-primary" href="#">
  16. <i class="icon-refresh icon-spin"></i> Synchronizing Content...</a>

按鈕組

 
  1. <div class="btn-group">
  2. <a class="btn" href="#"><i class="icon-align-left"></i></a>
  3. <a class="btn" href="#"><i class="icon-align-center"></i></a>
  4. <a class="btn" href="#"><i class="icon-align-right"></i></a>
  5. <a class="btn" href="#"><i class="icon-align-justify"></i></a>
  6. </div>

下拉菜單按鈕

 

  1. <div class="btn-group open">
  2. <a class="btn btn-primary" href="#"><i class="icon-user"></i> User</a>
  3. <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#"><span class="icon-caret-down"></span></a>
  4. <ul class="dropdown-menu">
  5. <li><a href="#"><i class="icon-pencil"></i> Edit</a></li>
  6. <li><a href="#"><i class="icon-trash"></i> Delete</a></li>
  7. <li><a href="#"><i class="icon-ban-circle"></i> Ban</a></li>
  8. <li class="divider"></li>
  9. <li><a href="#"><i class="i"></i> Make admin</a></li>
  10. </ul>
  11. </div>
Don't forget to add the appropriate JavaScript to enable button dropdowns.

列表

 

  • Lists
  • Buttons
  • Button groups
  • Navigation
  • Prepended form inputs

Easily replace individual bullets.

  1. <ul class="icons">
  2. <li><i class="icon-ok"></i> Lists</li>
  3. <li><i class="icon-ok"></i> Buttons</li>
  4. <li><i class="icon-ok"></i> Button groups</li>
  5. <li><i class="icon-ok"></i> Navigation</li>
  6. <li><i class="icon-ok"></i> Prepended form inputs</li>
  7. </ul>

導航條

Use Font Awesome icons in navigation to provide helpful visual cues.

  1. <ul class="nav nav-list">
  2. <li class="active"><a href="#"><i class="icon-home"></i> Home</a></li>
  3. <li><a href="#"><i class="icon-book"></i> Library</a></li>
  4. <li><a href="#"><i class="icon-pencil"></i> Applications</a></li>
  5. <li><a href="#"><i class="icon-cogs"></i> Settings</a></li>
  6. </ul>

Prepended form inputs

 

  1. <form>
  2. <div class="input-prepend">
  3. <span class="add-on"><i class="icon-envelope"></i></span>
  4. <input class="span2" type="text" placeholder="Email address">
  5. </div>
  6. <div class="input-prepend">
  7. <span class="add-on"><i class="icon-key"></i></span>
  8. <input class="span2" type="password" placeholder="Password">
  9. </div>
  10. </form>

自定義 CSS

普通字體能夠被賦予的CSS樣式也能一樣應用到 Font Awesome 上。

評定星級 (inspired by CSS Tricks)

 

Want to help make Font Awesome even more awesome? Contribute back to the Font Awesome community by designing new pictograms for the set.

If selected, you'll retain the CC-BY license to your pictogram and get attribution right here on the Font Awesome site.

How to Submit New Icons

  1. Download the icon-flag.pdf template.
  2. Open the PDF in Adobe Illustrator. You'll notice the file has dimensions of 60x56. This is exactly 4x the max icon size of 15 wide by 14 tall. The template is an example of the flag icon to use as a guide.
  3. Design your icon. In order to make it into the set, your icon must look pixel perfect. The easiest way to do this is to make sure your line widths in the template are some multiple of 4px. Diagonals are rough, too. Don't split pixels right down the middle, as they blur more when rendering. Zoom out to 25% to get a good idea of how it will render in the font.
  4. Submit your icon. Drop me an email at dave@davegandy.com. Make sure to use the subject [Font Awesome] [Icon Contribution] icon-name and attach your PDF file. If your icon makes it into Font Awesome (I'm keeping a very tight reign on quality), I'll ask what contact info you'd like to use for attribution.

下面是未來版本更新的計劃。

  • Easier sub-setting with icon packs.
  • More icons. Have any requests? Open an issue in the Font Awesome GitHub project.
  • Tricks and tips for super-awesome creative CSS methods, like the star example above.

I'm the lead product designer at Kyruus. I wake up every single day excited about my job. Why? Kyruus is going to change healthcare. No exaggeration.

Kyruus is a well-funded, big data healthcare startup in Boston. We believe that the right data at the right time can help doctors make better decisions. We believe data can save lives.

What I love about Kyruus:
  • Product design. From the top of the organization, Kyruus is committed to product design done right. It's awesome.
  • Purpose. Every day, I get to help make the world a better place – a little at a time.
  • People. I work with some of the best people I've ever met. More than just smart people. Good people.

Kyruus needs good people. Designers, app developers, big data masters, & interns that get real responsibility. Come work with me.

Interested? Email me.

Hopefully you think Font Awesome is awesome. I've put hundreds of hours into the project to give back to the open source community. If you'd like, here are some ways you can tell me thanks for all my hard work.

Contribute Icons

Contribute icons to make Font Awesome even awesome-er.

Help me buy an iMac

Contribute to a shiny new iMac for me to keep making great icons.

My Amazon Wish List

Or pick something straight from my wish list. Gift cards are great.

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息