demo_index.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>IconFont Demo</title>
  6. <link rel="shortcut icon" href="https://gtms04.alicdn.com/tps/i4/TB1_oz6GVXXXXaFXpXXJDFnIXXX-64-64.ico" type="image/x-icon"/>
  7. <link rel="stylesheet" href="https://g.alicdn.com/thx/cube/1.3.2/cube.min.css">
  8. <link rel="stylesheet" href="demo.css">
  9. <link rel="stylesheet" href="iconfont.css">
  10. <script src="iconfont.js"></script>
  11. <!-- jQuery -->
  12. <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/7bfddb60-08e8-11e9-9b04-53e73bb6408b.js"></script>
  13. <!-- 代码高亮 -->
  14. <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/a3f714d0-08e6-11e9-8a15-ebf944d7534c.js"></script>
  15. </head>
  16. <body>
  17. <div class="main">
  18. <h1 class="logo"><a href="https://www.iconfont.cn/" title="iconfont 首页" target="_blank">&#xe86b;</a></h1>
  19. <div class="nav-tabs">
  20. <ul id="tabs" class="dib-box">
  21. <li class="dib active"><span>Unicode</span></li>
  22. <li class="dib"><span>Font class</span></li>
  23. <li class="dib"><span>Symbol</span></li>
  24. </ul>
  25. <a href="https://www.iconfont.cn/manage/index?manage_type=myprojects&projectId=1709997" target="_blank" class="nav-more">查看项目</a>
  26. </div>
  27. <div class="tab-container">
  28. <div class="content unicode" style="display: block;">
  29. <ul class="icon_lists dib-box">
  30. <li class="dib">
  31. <span class="icon iconfont">&#xe635;</span>
  32. <div class="name">天气</div>
  33. <div class="code-name">&amp;#xe635;</div>
  34. </li>
  35. <li class="dib">
  36. <span class="icon iconfont">&#xe6a6;</span>
  37. <div class="name">风向</div>
  38. <div class="code-name">&amp;#xe6a6;</div>
  39. </li>
  40. <li class="dib">
  41. <span class="icon iconfont">&#xe606;</span>
  42. <div class="name">日照时长</div>
  43. <div class="code-name">&amp;#xe606;</div>
  44. </li>
  45. <li class="dib">
  46. <span class="icon iconfont">&#xe735;</span>
  47. <div class="name">温度</div>
  48. <div class="code-name">&amp;#xe735;</div>
  49. </li>
  50. <li class="dib">
  51. <span class="icon iconfont">&#xe686;</span>
  52. <div class="name">sk最低温度-允乐MinTemp</div>
  53. <div class="code-name">&amp;#xe686;</div>
  54. </li>
  55. <li class="dib">
  56. <span class="icon iconfont">&#xe687;</span>
  57. <div class="name">sk最高温度-允乐MaxTemp</div>
  58. <div class="code-name">&amp;#xe687;</div>
  59. </li>
  60. <li class="dib">
  61. <span class="icon iconfont">&#xe65a;</span>
  62. <div class="name">风速</div>
  63. <div class="code-name">&amp;#xe65a;</div>
  64. </li>
  65. <li class="dib">
  66. <span class="icon iconfont">&#xe60f;</span>
  67. <div class="name">气温</div>
  68. <div class="code-name">&amp;#xe60f;</div>
  69. </li>
  70. <li class="dib">
  71. <span class="icon iconfont">&#xe603;</span>
  72. <div class="name">温度</div>
  73. <div class="code-name">&amp;#xe603;</div>
  74. </li>
  75. <li class="dib">
  76. <span class="icon iconfont">&#xe654;</span>
  77. <div class="name">天气</div>
  78. <div class="code-name">&amp;#xe654;</div>
  79. </li>
  80. <li class="dib">
  81. <span class="icon iconfont">&#xe611;</span>
  82. <div class="name">风速</div>
  83. <div class="code-name">&amp;#xe611;</div>
  84. </li>
  85. <li class="dib">
  86. <span class="icon iconfont">&#xe6c0;</span>
  87. <div class="name">风速</div>
  88. <div class="code-name">&amp;#xe6c0;</div>
  89. </li>
  90. <li class="dib">
  91. <span class="icon iconfont">&#xe645;</span>
  92. <div class="name">天气</div>
  93. <div class="code-name">&amp;#xe645;</div>
  94. </li>
  95. <li class="dib">
  96. <span class="icon iconfont">&#xe600;</span>
  97. <div class="name">风向</div>
  98. <div class="code-name">&amp;#xe600;</div>
  99. </li>
  100. <li class="dib">
  101. <span class="icon iconfont">&#xe618;</span>
  102. <div class="name">降水量</div>
  103. <div class="code-name">&amp;#xe618;</div>
  104. </li>
  105. <li class="dib">
  106. <span class="icon iconfont">&#xe61b;</span>
  107. <div class="name">降水量</div>
  108. <div class="code-name">&amp;#xe61b;</div>
  109. </li>
  110. <li class="dib">
  111. <span class="icon iconfont">&#xe744;</span>
  112. <div class="name">日出</div>
  113. <div class="code-name">&amp;#xe744;</div>
  114. </li>
  115. <li class="dib">
  116. <span class="icon iconfont">&#xe746;</span>
  117. <div class="name">日落</div>
  118. <div class="code-name">&amp;#xe746;</div>
  119. </li>
  120. <li class="dib">
  121. <span class="icon iconfont">&#xe64b;</span>
  122. <div class="name">风速</div>
  123. <div class="code-name">&amp;#xe64b;</div>
  124. </li>
  125. <li class="dib">
  126. <span class="icon iconfont">&#xe688;</span>
  127. <div class="name">气温</div>
  128. <div class="code-name">&amp;#xe688;</div>
  129. </li>
  130. </ul>
  131. <div class="article markdown">
  132. <h2 id="unicode-">Unicode 引用</h2>
  133. <hr>
  134. <p>Unicode 是字体在网页端最原始的应用方式,特点是:</p>
  135. <ul>
  136. <li>兼容性最好,支持 IE6+,及所有现代浏览器。</li>
  137. <li>支持按字体的方式去动态调整图标大小,颜色等等。</li>
  138. <li>但是因为是字体,所以不支持多色。只能使用平台里单色的图标,就算项目里有多色图标也会自动去色。</li>
  139. </ul>
  140. <blockquote>
  141. <p>注意:新版 iconfont 支持多色图标,这些多色图标在 Unicode 模式下将不能使用,如果有需求建议使用symbol 的引用方式</p>
  142. </blockquote>
  143. <p>Unicode 使用步骤如下:</p>
  144. <h3 id="-font-face">第一步:拷贝项目下面生成的 <code>@font-face</code></h3>
  145. <pre><code class="language-css"
  146. >@font-face {
  147. font-family: 'iconfont';
  148. src: url('iconfont.eot');
  149. src: url('iconfont.eot?#iefix') format('embedded-opentype'),
  150. url('iconfont.woff2') format('woff2'),
  151. url('iconfont.woff') format('woff'),
  152. url('iconfont.ttf') format('truetype'),
  153. url('iconfont.svg#iconfont') format('svg');
  154. }
  155. </code></pre>
  156. <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
  157. <pre><code class="language-css"
  158. >.iconfont {
  159. font-family: "iconfont" !important;
  160. font-size: 16px;
  161. font-style: normal;
  162. -webkit-font-smoothing: antialiased;
  163. -moz-osx-font-smoothing: grayscale;
  164. }
  165. </code></pre>
  166. <h3 id="-">第三步:挑选相应图标并获取字体编码,应用于页面</h3>
  167. <pre>
  168. <code class="language-html"
  169. >&lt;span class="iconfont"&gt;&amp;#x33;&lt;/span&gt;
  170. </code></pre>
  171. <blockquote>
  172. <p>"iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。</p>
  173. </blockquote>
  174. </div>
  175. </div>
  176. <div class="content font-class">
  177. <ul class="icon_lists dib-box">
  178. <li class="dib">
  179. <span class="icon iconfont icon-weather"></span>
  180. <div class="name">
  181. 天气
  182. </div>
  183. <div class="code-name">.icon-weather
  184. </div>
  185. </li>
  186. <li class="dib">
  187. <span class="icon iconfont icon-dayWindDirection"></span>
  188. <div class="name">
  189. 风向
  190. </div>
  191. <div class="code-name">.icon-dayWindDirection
  192. </div>
  193. </li>
  194. <li class="dib">
  195. <span class="icon iconfont icon-sunDuration"></span>
  196. <div class="name">
  197. 日照时长
  198. </div>
  199. <div class="code-name">.icon-sunDuration
  200. </div>
  201. </li>
  202. <li class="dib">
  203. <span class="icon iconfont icon-nightRealFeel"></span>
  204. <div class="name">
  205. 温度
  206. </div>
  207. <div class="code-name">.icon-nightRealFeel
  208. </div>
  209. </li>
  210. <li class="dib">
  211. <span class="icon iconfont icon-minTemperature"></span>
  212. <div class="name">
  213. sk最低温度-允乐MinTemp
  214. </div>
  215. <div class="code-name">.icon-minTemperature
  216. </div>
  217. </li>
  218. <li class="dib">
  219. <span class="icon iconfont icon-maxTemperature"></span>
  220. <div class="name">
  221. sk最高温度-允乐MaxTemp
  222. </div>
  223. <div class="code-name">.icon-maxTemperature
  224. </div>
  225. </li>
  226. <li class="dib">
  227. <span class="icon iconfont icon-nightWindSpeed"></span>
  228. <div class="name">
  229. 风速
  230. </div>
  231. <div class="code-name">.icon-nightWindSpeed
  232. </div>
  233. </li>
  234. <li class="dib">
  235. <span class="icon iconfont icon-nightTemperature"></span>
  236. <div class="name">
  237. 气温
  238. </div>
  239. <div class="code-name">.icon-nightTemperature
  240. </div>
  241. </li>
  242. <li class="dib">
  243. <span class="icon iconfont icon-dayRealFeel"></span>
  244. <div class="name">
  245. 温度
  246. </div>
  247. <div class="code-name">.icon-dayRealFeel
  248. </div>
  249. </li>
  250. <li class="dib">
  251. <span class="icon iconfont icon-dayWeather"></span>
  252. <div class="name">
  253. 天气
  254. </div>
  255. <div class="code-name">.icon-dayWeather
  256. </div>
  257. </li>
  258. <li class="dib">
  259. <span class="icon iconfont icon-dayGust"></span>
  260. <div class="name">
  261. 风速
  262. </div>
  263. <div class="code-name">.icon-dayGust
  264. </div>
  265. </li>
  266. <li class="dib">
  267. <span class="icon iconfont icon-nightGust"></span>
  268. <div class="name">
  269. 风速
  270. </div>
  271. <div class="code-name">.icon-nightGust
  272. </div>
  273. </li>
  274. <li class="dib">
  275. <span class="icon iconfont icon-nightWeather"></span>
  276. <div class="name">
  277. 天气
  278. </div>
  279. <div class="code-name">.icon-nightWeather
  280. </div>
  281. </li>
  282. <li class="dib">
  283. <span class="icon iconfont icon-nightWindDirection"></span>
  284. <div class="name">
  285. 风向
  286. </div>
  287. <div class="code-name">.icon-nightWindDirection
  288. </div>
  289. </li>
  290. <li class="dib">
  291. <span class="icon iconfont icon-nightPrecipitation"></span>
  292. <div class="name">
  293. 降水量
  294. </div>
  295. <div class="code-name">.icon-nightPrecipitation
  296. </div>
  297. </li>
  298. <li class="dib">
  299. <span class="icon iconfont icon-dayPrecipitation"></span>
  300. <div class="name">
  301. 降水量
  302. </div>
  303. <div class="code-name">.icon-dayPrecipitation
  304. </div>
  305. </li>
  306. <li class="dib">
  307. <span class="icon iconfont icon-sunRise"></span>
  308. <div class="name">
  309. 日出
  310. </div>
  311. <div class="code-name">.icon-sunRise
  312. </div>
  313. </li>
  314. <li class="dib">
  315. <span class="icon iconfont icon-sunSet"></span>
  316. <div class="name">
  317. 日落
  318. </div>
  319. <div class="code-name">.icon-sunSet
  320. </div>
  321. </li>
  322. <li class="dib">
  323. <span class="icon iconfont icon-dayWindSpeed"></span>
  324. <div class="name">
  325. 风速
  326. </div>
  327. <div class="code-name">.icon-dayWindSpeed
  328. </div>
  329. </li>
  330. <li class="dib">
  331. <span class="icon iconfont icon-dayTemperature"></span>
  332. <div class="name">
  333. 气温
  334. </div>
  335. <div class="code-name">.icon-dayTemperature
  336. </div>
  337. </li>
  338. </ul>
  339. <div class="article markdown">
  340. <h2 id="font-class-">font-class 引用</h2>
  341. <hr>
  342. <p>font-class 是 Unicode 使用方式的一种变种,主要是解决 Unicode 书写不直观,语意不明确的问题。</p>
  343. <p>与 Unicode 使用方式相比,具有如下特点:</p>
  344. <ul>
  345. <li>兼容性良好,支持 IE8+,及所有现代浏览器。</li>
  346. <li>相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。</li>
  347. <li>因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。</li>
  348. <li>不过因为本质上还是使用的字体,所以多色图标还是不支持的。</li>
  349. </ul>
  350. <p>使用步骤如下:</p>
  351. <h3 id="-fontclass-">第一步:引入项目下面生成的 fontclass 代码:</h3>
  352. <pre><code class="language-html">&lt;link rel="stylesheet" href="./iconfont.css"&gt;
  353. </code></pre>
  354. <h3 id="-">第二步:挑选相应图标并获取类名,应用于页面:</h3>
  355. <pre><code class="language-html">&lt;span class="iconfont iconxxx"&gt;&lt;/span&gt;
  356. </code></pre>
  357. <blockquote>
  358. <p>"
  359. iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。</p>
  360. </blockquote>
  361. </div>
  362. </div>
  363. <div class="content symbol">
  364. <ul class="icon_lists dib-box">
  365. <li class="dib">
  366. <svg class="icon svg-icon" aria-hidden="true">
  367. <use xlink:href="#icon-weather"></use>
  368. </svg>
  369. <div class="name">天气</div>
  370. <div class="code-name">#icon-weather</div>
  371. </li>
  372. <li class="dib">
  373. <svg class="icon svg-icon" aria-hidden="true">
  374. <use xlink:href="#icon-dayWindDirection"></use>
  375. </svg>
  376. <div class="name">风向</div>
  377. <div class="code-name">#icon-dayWindDirection</div>
  378. </li>
  379. <li class="dib">
  380. <svg class="icon svg-icon" aria-hidden="true">
  381. <use xlink:href="#icon-sunDuration"></use>
  382. </svg>
  383. <div class="name">日照时长</div>
  384. <div class="code-name">#icon-sunDuration</div>
  385. </li>
  386. <li class="dib">
  387. <svg class="icon svg-icon" aria-hidden="true">
  388. <use xlink:href="#icon-nightRealFeel"></use>
  389. </svg>
  390. <div class="name">温度</div>
  391. <div class="code-name">#icon-nightRealFeel</div>
  392. </li>
  393. <li class="dib">
  394. <svg class="icon svg-icon" aria-hidden="true">
  395. <use xlink:href="#icon-minTemperature"></use>
  396. </svg>
  397. <div class="name">sk最低温度-允乐MinTemp</div>
  398. <div class="code-name">#icon-minTemperature</div>
  399. </li>
  400. <li class="dib">
  401. <svg class="icon svg-icon" aria-hidden="true">
  402. <use xlink:href="#icon-maxTemperature"></use>
  403. </svg>
  404. <div class="name">sk最高温度-允乐MaxTemp</div>
  405. <div class="code-name">#icon-maxTemperature</div>
  406. </li>
  407. <li class="dib">
  408. <svg class="icon svg-icon" aria-hidden="true">
  409. <use xlink:href="#icon-nightWindSpeed"></use>
  410. </svg>
  411. <div class="name">风速</div>
  412. <div class="code-name">#icon-nightWindSpeed</div>
  413. </li>
  414. <li class="dib">
  415. <svg class="icon svg-icon" aria-hidden="true">
  416. <use xlink:href="#icon-nightTemperature"></use>
  417. </svg>
  418. <div class="name">气温</div>
  419. <div class="code-name">#icon-nightTemperature</div>
  420. </li>
  421. <li class="dib">
  422. <svg class="icon svg-icon" aria-hidden="true">
  423. <use xlink:href="#icon-dayRealFeel"></use>
  424. </svg>
  425. <div class="name">温度</div>
  426. <div class="code-name">#icon-dayRealFeel</div>
  427. </li>
  428. <li class="dib">
  429. <svg class="icon svg-icon" aria-hidden="true">
  430. <use xlink:href="#icon-dayWeather"></use>
  431. </svg>
  432. <div class="name">天气</div>
  433. <div class="code-name">#icon-dayWeather</div>
  434. </li>
  435. <li class="dib">
  436. <svg class="icon svg-icon" aria-hidden="true">
  437. <use xlink:href="#icon-dayGust"></use>
  438. </svg>
  439. <div class="name">风速</div>
  440. <div class="code-name">#icon-dayGust</div>
  441. </li>
  442. <li class="dib">
  443. <svg class="icon svg-icon" aria-hidden="true">
  444. <use xlink:href="#icon-nightGust"></use>
  445. </svg>
  446. <div class="name">风速</div>
  447. <div class="code-name">#icon-nightGust</div>
  448. </li>
  449. <li class="dib">
  450. <svg class="icon svg-icon" aria-hidden="true">
  451. <use xlink:href="#icon-nightWeather"></use>
  452. </svg>
  453. <div class="name">天气</div>
  454. <div class="code-name">#icon-nightWeather</div>
  455. </li>
  456. <li class="dib">
  457. <svg class="icon svg-icon" aria-hidden="true">
  458. <use xlink:href="#icon-nightWindDirection"></use>
  459. </svg>
  460. <div class="name">风向</div>
  461. <div class="code-name">#icon-nightWindDirection</div>
  462. </li>
  463. <li class="dib">
  464. <svg class="icon svg-icon" aria-hidden="true">
  465. <use xlink:href="#icon-nightPrecipitation"></use>
  466. </svg>
  467. <div class="name">降水量</div>
  468. <div class="code-name">#icon-nightPrecipitation</div>
  469. </li>
  470. <li class="dib">
  471. <svg class="icon svg-icon" aria-hidden="true">
  472. <use xlink:href="#icon-dayPrecipitation"></use>
  473. </svg>
  474. <div class="name">降水量</div>
  475. <div class="code-name">#icon-dayPrecipitation</div>
  476. </li>
  477. <li class="dib">
  478. <svg class="icon svg-icon" aria-hidden="true">
  479. <use xlink:href="#icon-sunRise"></use>
  480. </svg>
  481. <div class="name">日出</div>
  482. <div class="code-name">#icon-sunRise</div>
  483. </li>
  484. <li class="dib">
  485. <svg class="icon svg-icon" aria-hidden="true">
  486. <use xlink:href="#icon-sunSet"></use>
  487. </svg>
  488. <div class="name">日落</div>
  489. <div class="code-name">#icon-sunSet</div>
  490. </li>
  491. <li class="dib">
  492. <svg class="icon svg-icon" aria-hidden="true">
  493. <use xlink:href="#icon-dayWindSpeed"></use>
  494. </svg>
  495. <div class="name">风速</div>
  496. <div class="code-name">#icon-dayWindSpeed</div>
  497. </li>
  498. <li class="dib">
  499. <svg class="icon svg-icon" aria-hidden="true">
  500. <use xlink:href="#icon-dayTemperature"></use>
  501. </svg>
  502. <div class="name">气温</div>
  503. <div class="code-name">#icon-dayTemperature</div>
  504. </li>
  505. </ul>
  506. <div class="article markdown">
  507. <h2 id="symbol-">Symbol 引用</h2>
  508. <hr>
  509. <p>这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇<a href="">文章</a>
  510. 这种用法其实是做了一个 SVG 的集合,与另外两种相比具有如下特点:</p>
  511. <ul>
  512. <li>支持多色图标了,不再受单色限制。</li>
  513. <li>通过一些技巧,支持像字体那样,通过 <code>font-size</code>, <code>color</code> 来调整样式。</li>
  514. <li>兼容性较差,支持 IE9+,及现代浏览器。</li>
  515. <li>浏览器渲染 SVG 的性能一般,还不如 png。</li>
  516. </ul>
  517. <p>使用步骤如下:</p>
  518. <h3 id="-symbol-">第一步:引入项目下面生成的 symbol 代码:</h3>
  519. <pre><code class="language-html">&lt;script src="./iconfont.js"&gt;&lt;/script&gt;
  520. </code></pre>
  521. <h3 id="-css-">第二步:加入通用 CSS 代码(引入一次就行):</h3>
  522. <pre><code class="language-html">&lt;style&gt;
  523. .icon {
  524. width: 1em;
  525. height: 1em;
  526. vertical-align: -0.15em;
  527. fill: currentColor;
  528. overflow: hidden;
  529. }
  530. &lt;/style&gt;
  531. </code></pre>
  532. <h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3>
  533. <pre><code class="language-html">&lt;svg class="icon" aria-hidden="true"&gt;
  534. &lt;use xlink:href="#icon-xxx"&gt;&lt;/use&gt;
  535. &lt;/svg&gt;
  536. </code></pre>
  537. </div>
  538. </div>
  539. </div>
  540. </div>
  541. <script>
  542. $(document).ready(function () {
  543. $('.tab-container .content:first').show()
  544. $('#tabs li').click(function (e) {
  545. var tabContent = $('.tab-container .content')
  546. var index = $(this).index()
  547. if ($(this).hasClass('active')) {
  548. return
  549. } else {
  550. $('#tabs li').removeClass('active')
  551. $(this).addClass('active')
  552. tabContent.hide().eq(index).fadeIn()
  553. }
  554. })
  555. })
  556. </script>
  557. </body>
  558. </html>