demo_symbol.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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-add"></use>
  29. </svg>
  30. <div class="name">add</div>
  31. <div class="fontclass">#icon-add</div>
  32. </li>
  33. <li>
  34. <svg class="icon" aria-hidden="true">
  35. <use xlink:href="#icon-gongdan"></use>
  36. </svg>
  37. <div class="name">gongdan2</div>
  38. <div class="fontclass">#icon-gongdan</div>
  39. </li>
  40. <li>
  41. <svg class="icon" aria-hidden="true">
  42. <use xlink:href="#icon-gongdan1"></use>
  43. </svg>
  44. <div class="name">gongdan</div>
  45. <div class="fontclass">#icon-gongdan1</div>
  46. </li>
  47. <li>
  48. <svg class="icon" aria-hidden="true">
  49. <use xlink:href="#icon-home"></use>
  50. </svg>
  51. <div class="name">home</div>
  52. <div class="fontclass">#icon-home</div>
  53. </li>
  54. <li>
  55. <svg class="icon" aria-hidden="true">
  56. <use xlink:href="#icon-more"></use>
  57. </svg>
  58. <div class="name">more</div>
  59. <div class="fontclass">#icon-more</div>
  60. </li>
  61. <li>
  62. <svg class="icon" aria-hidden="true">
  63. <use xlink:href="#icon-message"></use>
  64. </svg>
  65. <div class="name">message</div>
  66. <div class="fontclass">#icon-message</div>
  67. </li>
  68. <li>
  69. <svg class="icon" aria-hidden="true">
  70. <use xlink:href="#icon-peo"></use>
  71. </svg>
  72. <div class="name">peo2</div>
  73. <div class="fontclass">#icon-peo</div>
  74. </li>
  75. <li>
  76. <svg class="icon" aria-hidden="true">
  77. <use xlink:href="#icon-people"></use>
  78. </svg>
  79. <div class="name">people</div>
  80. <div class="fontclass">#icon-people</div>
  81. </li>
  82. <li>
  83. <svg class="icon" aria-hidden="true">
  84. <use xlink:href="#icon-peo1"></use>
  85. </svg>
  86. <div class="name">peo3</div>
  87. <div class="fontclass">#icon-peo1</div>
  88. </li>
  89. <li>
  90. <svg class="icon" aria-hidden="true">
  91. <use xlink:href="#icon-search"></use>
  92. </svg>
  93. <div class="name">search</div>
  94. <div class="fontclass">#icon-search</div>
  95. </li>
  96. <li>
  97. <svg class="icon" aria-hidden="true">
  98. <use xlink:href="#icon-sort"></use>
  99. </svg>
  100. <div class="name">sort1</div>
  101. <div class="fontclass">#icon-sort</div>
  102. </li>
  103. <li>
  104. <svg class="icon" aria-hidden="true">
  105. <use xlink:href="#icon-start"></use>
  106. </svg>
  107. <div class="name">start</div>
  108. <div class="fontclass">#icon-start</div>
  109. </li>
  110. <li>
  111. <svg class="icon" aria-hidden="true">
  112. <use xlink:href="#icon-start1"></use>
  113. </svg>
  114. <div class="name">start 2</div>
  115. <div class="fontclass">#icon-start1</div>
  116. </li>
  117. <li>
  118. <svg class="icon" aria-hidden="true">
  119. <use xlink:href="#icon-anquancanshu"></use>
  120. </svg>
  121. <div class="name">安全参数</div>
  122. <div class="fontclass">#icon-anquancanshu</div>
  123. </li>
  124. <li>
  125. <svg class="icon" aria-hidden="true">
  126. <use xlink:href="#icon-dangqianbaojing"></use>
  127. </svg>
  128. <div class="name">当前报警</div>
  129. <div class="fontclass">#icon-dangqianbaojing</div>
  130. </li>
  131. <li>
  132. <svg class="icon" aria-hidden="true">
  133. <use xlink:href="#icon-huanjing"></use>
  134. </svg>
  135. <div class="name">环境</div>
  136. <div class="fontclass">#icon-huanjing</div>
  137. </li>
  138. <li>
  139. <svg class="icon" aria-hidden="true">
  140. <use xlink:href="#icon-huanjinglogo"></use>
  141. </svg>
  142. <div class="name">环境logo</div>
  143. <div class="fontclass">#icon-huanjinglogo</div>
  144. </li>
  145. <li>
  146. <svg class="icon" aria-hidden="true">
  147. <use xlink:href="#icon-huiyuanmanyidu"></use>
  148. </svg>
  149. <div class="name">会员满意度</div>
  150. <div class="fontclass">#icon-huiyuanmanyidu</div>
  151. </li>
  152. <li>
  153. <svg class="icon" aria-hidden="true">
  154. <use xlink:href="#icon-jiancedian"></use>
  155. </svg>
  156. <div class="name">监测点</div>
  157. <div class="fontclass">#icon-jiancedian</div>
  158. </li>
  159. <li>
  160. <svg class="icon" aria-hidden="true">
  161. <use xlink:href="#icon-lengzhanlogo"></use>
  162. </svg>
  163. <div class="name">冷站logo</div>
  164. <div class="fontclass">#icon-lengzhanlogo</div>
  165. </li>
  166. <li>
  167. <svg class="icon" aria-hidden="true">
  168. <use xlink:href="#icon-nengyuanlogo"></use>
  169. </svg>
  170. <div class="name">能源logo</div>
  171. <div class="fontclass">#icon-nengyuanlogo</div>
  172. </li>
  173. <li>
  174. <svg class="icon" aria-hidden="true">
  175. <use xlink:href="#icon-pingfen"></use>
  176. </svg>
  177. <div class="name">评分</div>
  178. <div class="fontclass">#icon-pingfen</div>
  179. </li>
  180. <li>
  181. <svg class="icon" aria-hidden="true">
  182. <use xlink:href="#icon-peidianlogo"></use>
  183. </svg>
  184. <div class="name">配电logo</div>
  185. <div class="fontclass">#icon-peidianlogo</div>
  186. </li>
  187. <li>
  188. <svg class="icon" aria-hidden="true">
  189. <use xlink:href="#icon-qushi"></use>
  190. </svg>
  191. <div class="name">趋势</div>
  192. <div class="fontclass">#icon-qushi</div>
  193. </li>
  194. <li>
  195. <svg class="icon" aria-hidden="true">
  196. <use xlink:href="#icon-qiangdianzhuanyexitong"></use>
  197. </svg>
  198. <div class="name">强电专业系统</div>
  199. <div class="fontclass">#icon-qiangdianzhuanyexitong</div>
  200. </li>
  201. <li>
  202. <svg class="icon" aria-hidden="true">
  203. <use xlink:href="#icon-shenghuoreshui"></use>
  204. </svg>
  205. <div class="name">生活热水</div>
  206. <div class="fontclass">#icon-shenghuoreshui</div>
  207. </li>
  208. <li>
  209. <svg class="icon" aria-hidden="true">
  210. <use xlink:href="#icon-xiangmudafenbiao"></use>
  211. </svg>
  212. <div class="name">项目打分表</div>
  213. <div class="fontclass">#icon-xiangmudafenbiao</div>
  214. </li>
  215. <li>
  216. <svg class="icon" aria-hidden="true">
  217. <use xlink:href="#icon-kongzhuangtaiicon"></use>
  218. </svg>
  219. <div class="name">空状态icon</div>
  220. <div class="fontclass">#icon-kongzhuangtaiicon</div>
  221. </li>
  222. <li>
  223. <svg class="icon" aria-hidden="true">
  224. <use xlink:href="#icon-tongjifenxiblue"></use>
  225. </svg>
  226. <div class="name">统计分析blue</div>
  227. <div class="fontclass">#icon-tongjifenxiblue</div>
  228. </li>
  229. <li>
  230. <svg class="icon" aria-hidden="true">
  231. <use xlink:href="#icon-yujing"></use>
  232. </svg>
  233. <div class="name">预警</div>
  234. <div class="fontclass">#icon-yujing</div>
  235. </li>
  236. <li>
  237. <svg class="icon" aria-hidden="true">
  238. <use xlink:href="#icon-zonglan"></use>
  239. </svg>
  240. <div class="name">总览</div>
  241. <div class="fontclass">#icon-zonglan</div>
  242. </li>
  243. <li>
  244. <svg class="icon" aria-hidden="true">
  245. <use xlink:href="#icon-zulinlogo"></use>
  246. </svg>
  247. <div class="name">租赁logo</div>
  248. <div class="fontclass">#icon-zulinlogo</div>
  249. </li>
  250. <li>
  251. <svg class="icon" aria-hidden="true">
  252. <use xlink:href="#icon-zhanghao"></use>
  253. </svg>
  254. <div class="name">账号</div>
  255. <div class="fontclass">#icon-zhanghao</div>
  256. </li>
  257. <li>
  258. <svg class="icon" aria-hidden="true">
  259. <use xlink:href="#icon-close"></use>
  260. </svg>
  261. <div class="name">close</div>
  262. <div class="fontclass">#icon-close</div>
  263. </li>
  264. <li>
  265. <svg class="icon" aria-hidden="true">
  266. <use xlink:href="#icon-mima"></use>
  267. </svg>
  268. <div class="name">密码</div>
  269. <div class="fontclass">#icon-mima</div>
  270. </li>
  271. <li>
  272. <svg class="icon" aria-hidden="true">
  273. <use xlink:href="#icon-meos"></use>
  274. </svg>
  275. <div class="name">meos</div>
  276. <div class="fontclass">#icon-meos</div>
  277. </li>
  278. </ul>
  279. <h2 id="symbol-">symbol引用</h2>
  280. <hr>
  281. <p>这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇<a href="">文章</a>
  282. 这种用法其实是做了一个svg的集合,与另外两种相比具有如下特点:</p>
  283. <ul>
  284. <li>支持多色图标了,不再受单色限制。</li>
  285. <li>通过一些技巧,支持像字体那样,通过<code>font-size</code>,<code>color</code>来调整样式。</li>
  286. <li>兼容性较差,支持 ie9+,及现代浏览器。</li>
  287. <li>浏览器渲染svg的性能一般,还不如png。</li>
  288. </ul>
  289. <p>使用步骤如下:</p>
  290. <h3 id="-symbol-">第一步:引入项目下面生成的symbol代码:</h3>
  291. <pre><code class="lang-js hljs javascript"><span class="hljs-comment">&lt;script src="./iconfont.js"&gt;&lt;/script&gt;</span></code></pre>
  292. <h3 id="-css-">第二步:加入通用css代码(引入一次就行):</h3>
  293. <pre><code class="lang-js hljs javascript">&lt;style type=<span class="hljs-string">"text/css"</span>&gt;
  294. .icon {
  295. width: <span class="hljs-number">1</span>em; height: <span class="hljs-number">1</span>em;
  296. vertical-align: <span class="hljs-number">-0.15</span>em;
  297. fill: currentColor;
  298. overflow: hidden;
  299. }
  300. &lt;<span class="hljs-regexp">/style&gt;</span></code></pre>
  301. <h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3>
  302. <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">
  303. &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>
  304. </span>&lt;<span class="hljs-regexp">/svg&gt;
  305. </span></code></pre>
  306. </div>
  307. </body>
  308. </html>