demo_symbol.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>IconFont</title>
  6. <link rel="stylesheet" href="demo.css">
  7. <script src="iconfont.js"></script>
  8. <style type="text/css">
  9. .icon {
  10. /* 通过设置 font-size 来改变图标大小 */
  11. width: 1em; height: 1em;
  12. /* 图标和文字相邻时,垂直对齐 */
  13. vertical-align: -0.15em;
  14. /* 通过设置 color 来改变 SVG 的颜色/fill */
  15. fill: currentColor;
  16. /* path 和 stroke 溢出 viewBox 部分在 IE 下会显示
  17. normalize.css 中也包含这行 */
  18. overflow: hidden;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div class="main markdown">
  24. <h1>IconFont 图标</h1>
  25. <ul class="icon_lists clear">
  26. <li>
  27. <svg class="icon" aria-hidden="true">
  28. <use xlink:href="#icon-msnui-poweroff"></use>
  29. </svg>
  30. <div class="name">关机</div>
  31. <div class="fontclass">#icon-msnui-poweroff</div>
  32. </li>
  33. <li>
  34. <svg class="icon" aria-hidden="true">
  35. <use xlink:href="#icon-close"></use>
  36. </svg>
  37. <div class="name">close</div>
  38. <div class="fontclass">#icon-close</div>
  39. </li>
  40. <li>
  41. <svg class="icon" aria-hidden="true">
  42. <use xlink:href="#icon-shanchu"></use>
  43. </svg>
  44. <div class="name">删除</div>
  45. <div class="fontclass">#icon-shanchu</div>
  46. </li>
  47. <li>
  48. <svg class="icon" aria-hidden="true">
  49. <use xlink:href="#icon-quanping"></use>
  50. </svg>
  51. <div class="name">全屏</div>
  52. <div class="fontclass">#icon-quanping</div>
  53. </li>
  54. <li>
  55. <svg class="icon" aria-hidden="true">
  56. <use xlink:href="#icon-shanchu1"></use>
  57. </svg>
  58. <div class="name">删除</div>
  59. <div class="fontclass">#icon-shanchu1</div>
  60. </li>
  61. <li>
  62. <svg class="icon" aria-hidden="true">
  63. <use xlink:href="#icon-weibiaoti-_huabanfuben"></use>
  64. </svg>
  65. <div class="name">未标题-1_画板 1 副本 6</div>
  66. <div class="fontclass">#icon-weibiaoti-_huabanfuben</div>
  67. </li>
  68. <li>
  69. <svg class="icon" aria-hidden="true">
  70. <use xlink:href="#icon-weibiaoti-_huabanfuben1"></use>
  71. </svg>
  72. <div class="name">未标题-1_画板 1 副本 7</div>
  73. <div class="fontclass">#icon-weibiaoti-_huabanfuben1</div>
  74. </li>
  75. <li>
  76. <svg class="icon" aria-hidden="true">
  77. <use xlink:href="#icon-weibiaoti-_huabanfuben2"></use>
  78. </svg>
  79. <div class="name">未标题-1_画板 1 副本 11</div>
  80. <div class="fontclass">#icon-weibiaoti-_huabanfuben2</div>
  81. </li>
  82. <li>
  83. <svg class="icon" aria-hidden="true">
  84. <use xlink:href="#icon-weibiaoti-_huabanfuben3"></use>
  85. </svg>
  86. <div class="name">未标题-1_画板 1 副本 10</div>
  87. <div class="fontclass">#icon-weibiaoti-_huabanfuben3</div>
  88. </li>
  89. <li>
  90. <svg class="icon" aria-hidden="true">
  91. <use xlink:href="#icon-weibiaoti-_huabanfuben4"></use>
  92. </svg>
  93. <div class="name">未标题-1_画板 1 副本 9</div>
  94. <div class="fontclass">#icon-weibiaoti-_huabanfuben4</div>
  95. </li>
  96. <li>
  97. <svg class="icon" aria-hidden="true">
  98. <use xlink:href="#icon-weibiaoti-_huabanfuben5"></use>
  99. </svg>
  100. <div class="name">未标题-1_画板 1 副本 8</div>
  101. <div class="fontclass">#icon-weibiaoti-_huabanfuben5</div>
  102. </li>
  103. <li>
  104. <svg class="icon" aria-hidden="true">
  105. <use xlink:href="#icon-weibiaoti-_Time-active"></use>
  106. </svg>
  107. <div class="name">未标题-1_Time-active</div>
  108. <div class="fontclass">#icon-weibiaoti-_Time-active</div>
  109. </li>
  110. <li>
  111. <svg class="icon" aria-hidden="true">
  112. <use xlink:href="#icon-weibiaoti-_b-active"></use>
  113. </svg>
  114. <div class="name">未标题-1_b-active</div>
  115. <div class="fontclass">#icon-weibiaoti-_b-active</div>
  116. </li>
  117. <li>
  118. <svg class="icon" aria-hidden="true">
  119. <use xlink:href="#icon-weibiaoti-_A-active"></use>
  120. </svg>
  121. <div class="name">未标题-1_A-active</div>
  122. <div class="fontclass">#icon-weibiaoti-_A-active</div>
  123. </li>
  124. <li>
  125. <svg class="icon" aria-hidden="true">
  126. <use xlink:href="#icon-weibiaoti-_Add-active"></use>
  127. </svg>
  128. <div class="name">未标题-1_Add-active</div>
  129. <div class="fontclass">#icon-weibiaoti-_Add-active</div>
  130. </li>
  131. <li>
  132. <svg class="icon" aria-hidden="true">
  133. <use xlink:href="#icon-weibiaoti-_center-active"></use>
  134. </svg>
  135. <div class="name">未标题-1_center-active</div>
  136. <div class="fontclass">#icon-weibiaoti-_center-active</div>
  137. </li>
  138. <li>
  139. <svg class="icon" aria-hidden="true">
  140. <use xlink:href="#icon-weibiaoti-_life-active"></use>
  141. </svg>
  142. <div class="name">未标题-1_life-active</div>
  143. <div class="fontclass">#icon-weibiaoti-_life-active</div>
  144. </li>
  145. <li>
  146. <svg class="icon" aria-hidden="true">
  147. <use xlink:href="#icon-weibiaoti-_youxu-active"></use>
  148. </svg>
  149. <div class="name">未标题-1_youxu-active</div>
  150. <div class="fontclass">#icon-weibiaoti-_youxu-active</div>
  151. </li>
  152. <li>
  153. <svg class="icon" aria-hidden="true">
  154. <use xlink:href="#icon-weibiaoti-_right-active"></use>
  155. </svg>
  156. <div class="name">未标题-1_right-active</div>
  157. <div class="fontclass">#icon-weibiaoti-_right-active</div>
  158. </li>
  159. <li>
  160. <svg class="icon" aria-hidden="true">
  161. <use xlink:href="#icon-weibiaoti-_U-active"></use>
  162. </svg>
  163. <div class="name">未标题-1_U-active</div>
  164. <div class="fontclass">#icon-weibiaoti-_U-active</div>
  165. </li>
  166. <li>
  167. <svg class="icon" aria-hidden="true">
  168. <use xlink:href="#icon-weibiaoti-_wuxu-active"></use>
  169. </svg>
  170. <div class="name">未标题-1_wuxu-active</div>
  171. <div class="fontclass">#icon-weibiaoti-_wuxu-active</div>
  172. </li>
  173. <li>
  174. <svg class="icon" aria-hidden="true">
  175. <use xlink:href="#icon-weibiaoti-_Pic-active"></use>
  176. </svg>
  177. <div class="name">未标题-1_Pic-active</div>
  178. <div class="fontclass">#icon-weibiaoti-_Pic-active</div>
  179. </li>
  180. <li>
  181. <svg class="icon" aria-hidden="true">
  182. <use xlink:href="#icon-weibiaoti-_I-active"></use>
  183. </svg>
  184. <div class="name">未标题-1_I-active</div>
  185. <div class="fontclass">#icon-weibiaoti-_I-active</div>
  186. </li>
  187. <li>
  188. <svg class="icon" aria-hidden="true">
  189. <use xlink:href="#icon-hebing"></use>
  190. </svg>
  191. <div class="name">合并 (1)</div>
  192. <div class="fontclass">#icon-hebing</div>
  193. </li>
  194. <li>
  195. <svg class="icon" aria-hidden="true">
  196. <use xlink:href="#icon-caijian"></use>
  197. </svg>
  198. <div class="name">裁剪</div>
  199. <div class="fontclass">#icon-caijian</div>
  200. </li>
  201. <li>
  202. <svg class="icon" aria-hidden="true">
  203. <use xlink:href="#icon-jianqie"></use>
  204. </svg>
  205. <div class="name">剪切</div>
  206. <div class="fontclass">#icon-jianqie</div>
  207. </li>
  208. <li>
  209. <svg class="icon" aria-hidden="true">
  210. <use xlink:href="#icon-xunhuan"></use>
  211. </svg>
  212. <div class="name">循环2</div>
  213. <div class="fontclass">#icon-xunhuan</div>
  214. </li>
  215. </ul>
  216. <h2 id="symbol-">symbol引用</h2>
  217. <hr>
  218. <p>这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇<a href="">文章</a>
  219. 这种用法其实是做了一个svg的集合,与另外两种相比具有如下特点:</p>
  220. <ul>
  221. <li>支持多色图标了,不再受单色限制。</li>
  222. <li>通过一些技巧,支持像字体那样,通过<code>font-size</code>,<code>color</code>来调整样式。</li>
  223. <li>兼容性较差,支持 ie9+,及现代浏览器。</li>
  224. <li>浏览器渲染svg的性能一般,还不如png。</li>
  225. </ul>
  226. <p>使用步骤如下:</p>
  227. <h3 id="-symbol-">第一步:引入项目下面生成的symbol代码:</h3>
  228. <pre><code class="lang-js hljs javascript"><span class="hljs-comment">&lt;script src="./iconfont.js"&gt;&lt;/script&gt;</span></code></pre>
  229. <h3 id="-css-">第二步:加入通用css代码(引入一次就行):</h3>
  230. <pre><code class="lang-js hljs javascript">&lt;style type=<span class="hljs-string">"text/css"</span>&gt;
  231. .icon {
  232. width: <span class="hljs-number">1</span>em; height: <span class="hljs-number">1</span>em;
  233. vertical-align: <span class="hljs-number">-0.15</span>em;
  234. fill: currentColor;
  235. overflow: hidden;
  236. }
  237. &lt;<span class="hljs-regexp">/style&gt;</span></code></pre>
  238. <h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3>
  239. <pre><code class="lang-js hljs javascript">&lt;svg <span class="hljs-class"><span class="hljs-keyword">class</span></span>=<span class="hljs-string">"icon"</span> aria-hidden=<span class="hljs-string">"true"</span>&gt;<span class="xml"><span class="hljs-tag">
  240. &lt;<span class="hljs-name">use</span> <span class="hljs-attr">xlink:href</span>=<span class="hljs-string">"#icon-xxx"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">use</span>&gt;</span>
  241. </span>&lt;<span class="hljs-regexp">/svg&gt;
  242. </span></code></pre>
  243. </div>
  244. </body>
  245. </html>