demo_unicode.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>IconFont</title>
  6. <link rel="stylesheet" href="demo.css">
  7. <style type="text/css">
  8. @font-face {font-family: "iconfont";
  9. src: url('iconfont.eot'); /* IE9*/
  10. src: url('iconfont.eot#iefix') format('embedded-opentype'), /* IE6-IE8 */
  11. url('iconfont.woff') format('woff'), /* chrome, firefox */
  12. url('iconfont.ttf') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
  13. url('iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
  14. }
  15. .iconfont {
  16. font-family:"iconfont" !important;
  17. font-size:16px;
  18. font-style:normal;
  19. -webkit-font-smoothing: antialiased;
  20. -webkit-text-stroke-width: 0.2px;
  21. -moz-osx-font-smoothing: grayscale;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <div class="main markdown">
  27. <h1>IconFont 图标</h1>
  28. <ul class="icon_lists clear">
  29. <li>
  30. <i class="icon iconfont">&#xe69a;</i>
  31. <div class="name">箭头-2</div>
  32. <div class="code">&amp;#xe69a;</div>
  33. </li>
  34. <li>
  35. <i class="icon iconfont">&#xe85a;</i>
  36. <div class="name">选中</div>
  37. <div class="code">&amp;#xe85a;</div>
  38. </li>
  39. <li>
  40. <i class="icon iconfont">&#xe6b1;</i>
  41. <div class="name">error</div>
  42. <div class="code">&amp;#xe6b1;</div>
  43. </li>
  44. <li>
  45. <i class="icon iconfont">&#xe6b2;</i>
  46. <div class="name">prompt</div>
  47. <div class="code">&amp;#xe6b2;</div>
  48. </li>
  49. <li>
  50. <i class="icon iconfont">&#xe6b3;</i>
  51. <div class="name">success</div>
  52. <div class="code">&amp;#xe6b3;</div>
  53. </li>
  54. <li>
  55. <i class="icon iconfont">&#xe6b6;</i>
  56. <div class="name">help</div>
  57. <div class="code">&amp;#xe6b6;</div>
  58. </li>
  59. <li>
  60. <i class="icon iconfont">&#xe653;</i>
  61. <div class="name">未选中</div>
  62. <div class="code">&amp;#xe653;</div>
  63. </li>
  64. </ul>
  65. <h2 id="unicode-">unicode引用</h2>
  66. <hr>
  67. <p>unicode是字体在网页端最原始的应用方式,特点是:</p>
  68. <ul>
  69. <li>兼容性最好,支持ie6+,及所有现代浏览器。</li>
  70. <li>支持按字体的方式去动态调整图标大小,颜色等等。</li>
  71. <li>但是因为是字体,所以不支持多色。只能使用平台里单色的图标,就算项目里有多色图标也会自动去色。</li>
  72. </ul>
  73. <blockquote>
  74. <p>注意:新版iconfont支持多色图标,这些多色图标在unicode模式下将不能使用,如果有需求建议使用symbol的引用方式</p>
  75. </blockquote>
  76. <p>unicode使用步骤如下:</p>
  77. <h3 id="-font-face">第一步:拷贝项目下面生成的font-face</h3>
  78. <pre><code class="lang-js hljs javascript">@font-face {
  79. font-family: <span class="hljs-string">'iconfont'</span>;
  80. src: url(<span class="hljs-string">'iconfont.eot'</span>);
  81. src: url(<span class="hljs-string">'iconfont.eot?#iefix'</span>) format(<span class="hljs-string">'embedded-opentype'</span>),
  82. url(<span class="hljs-string">'iconfont.woff'</span>) format(<span class="hljs-string">'woff'</span>),
  83. url(<span class="hljs-string">'iconfont.ttf'</span>) format(<span class="hljs-string">'truetype'</span>),
  84. url(<span class="hljs-string">'iconfont.svg#iconfont'</span>) format(<span class="hljs-string">'svg'</span>);
  85. }
  86. </code></pre>
  87. <h3 id="-iconfont-">第二步:定义使用iconfont的样式</h3>
  88. <pre><code class="lang-js hljs javascript">.iconfont{
  89. font-family:<span class="hljs-string">"iconfont"</span> !important;
  90. font-size:<span class="hljs-number">16</span>px;font-style:normal;
  91. -webkit-font-smoothing: antialiased;
  92. -webkit-text-stroke-width: <span class="hljs-number">0.2</span>px;
  93. -moz-osx-font-smoothing: grayscale;
  94. }
  95. </code></pre>
  96. <h3 id="-">第三步:挑选相应图标并获取字体编码,应用于页面</h3>
  97. <pre><code class="lang-js hljs javascript">&lt;i <span class="hljs-class"><span class="hljs-keyword">class</span></span>=<span class="hljs-string">"iconfont"</span>&gt;&amp;#x33;<span class="xml"><span class="hljs-tag">&lt;/<span class="hljs-name">i</span>&gt;</span></span></code></pre>
  98. <blockquote>
  99. <p>"iconfont"是你项目下的font-family。可以通过编辑项目查看,默认是"iconfont"。</p>
  100. </blockquote>
  101. </div>
  102. </body>
  103. </html>