主要特性
使用icon font來生成圖標相對於基於圖片的圖標來說,有如下的好處:
- 自由的變化大小
- 自由的修改顏色
- 添加陰影效果
- IE6也可以支持
- 支持圖片圖標的其它屬性,例如,透明度和旋轉等等
- 可以添加text-stroke和background-clip:text等屬性,只要瀏覽器支持
如何使用?
文字修飾:
- <font color="Black"> <h3>
- <span aria-hidden=”true” data-icon=”⇝”></span>
- Stats
- </h3>
- [data-icon]:before {
- font-family: icons; /* BYO icon font, mapped smartly */
- content: attr(data-icon);
- speak: none; /* Not to be trusted, but hey. */
- }</font>
單獨圖標:
- <font color="Black"> <a href=”#”>
- <span aria-hidden=”true” data-icon=”▨”></span>
- <span>RSS</span>
- </a>
- /* Same CSS as above, plus */
- .icon-alone {
- display: inline-block; /* Chrome 19 was weird with clickability without this */
- }
- .screen-reader-text { /* Reusable, toolbox kind of class */
- position: absolute;
- top: -9999px;
- left: -9999px;
- }</font>
如果大家需要創建自己的iconfont,推薦使用iconmoon,使用它你可以通過上傳SVG或者字體來生成你需要的icon字體,本文在線演示使用iconmoon生成。
步驟1:選擇他們提供的或者上傳自己的
步驟2:下載下來
然後我們解壓下看看文件
index.html就是樣例,font裏就是字體
好了這樣你就可以使用圖標字體了,可以根據自己的需要修改index文件。
本站演示效果:在線手冊
來源:PHP小鎮