demo_index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>iconfont Demo</title>
  6. <link rel="shortcut icon" href="//img.alicdn.com/imgextra/i2/O1CN01ZyAlrn1MwaMhqz36G_!!6000000001499-73-tps-64-64.ico" type="image/x-icon"/>
  7. <link rel="icon" type="image/svg+xml" href="//img.alicdn.com/imgextra/i4/O1CN01EYTRnJ297D6vehehJ_!!6000000008020-55-tps-64-64.svg"/>
  8. <link rel="stylesheet" href="https://g.alicdn.com/thx/cube/1.3.2/cube.min.css">
  9. <link rel="stylesheet" href="demo.css">
  10. <link rel="stylesheet" href="iconfont.css">
  11. <script src="iconfont.js"></script>
  12. <!-- jQuery -->
  13. <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/7bfddb60-08e8-11e9-9b04-53e73bb6408b.js"></script>
  14. <!-- 代码高亮 -->
  15. <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/a3f714d0-08e6-11e9-8a15-ebf944d7534c.js"></script>
  16. <style>
  17. .main .logo {
  18. margin-top: 0;
  19. height: auto;
  20. }
  21. .main .logo a {
  22. display: flex;
  23. align-items: center;
  24. }
  25. .main .logo .sub-title {
  26. margin-left: 0.5em;
  27. font-size: 22px;
  28. color: #fff;
  29. background: linear-gradient(-45deg, #3967FF, #B500FE);
  30. -webkit-background-clip: text;
  31. -webkit-text-fill-color: transparent;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div class="main">
  37. <h1 class="logo"><a href="https://www.iconfont.cn/" title="iconfont 首页" target="_blank">
  38. <img width="200" src="https://img.alicdn.com/imgextra/i3/O1CN01Mn65HV1FfSEzR6DKv_!!6000000000514-55-tps-228-59.svg">
  39. </a></h1>
  40. <div class="nav-tabs">
  41. <ul id="tabs" class="dib-box">
  42. <li class="dib active"><span>Unicode</span></li>
  43. <li class="dib"><span>Font class</span></li>
  44. <li class="dib"><span>Symbol</span></li>
  45. </ul>
  46. <a href="https://www.iconfont.cn/manage/index?manage_type=myprojects&projectId=2522399" target="_blank" class="nav-more">查看项目</a>
  47. </div>
  48. <div class="tab-container">
  49. <div class="content unicode" style="display: block;">
  50. <ul class="icon_lists dib-box">
  51. <li class="dib">
  52. <span class="icon iconfont">&#xe683;</span>
  53. <div class="name">cutting</div>
  54. <div class="code-name">&amp;#xe683;</div>
  55. </li>
  56. <li class="dib">
  57. <span class="icon iconfont">&#xe6a2;</span>
  58. <div class="name">model & plane-overlay</div>
  59. <div class="code-name">&amp;#xe6a2;</div>
  60. </li>
  61. <li class="dib">
  62. <span class="icon iconfont">&#xe6c0;</span>
  63. <div class="name">first view-filled</div>
  64. <div class="code-name">&amp;#xe6c0;</div>
  65. </li>
  66. <li class="dib">
  67. <span class="icon iconfont">&#xe6c1;</span>
  68. <div class="name">measure-area</div>
  69. <div class="code-name">&amp;#xe6c1;</div>
  70. </li>
  71. <li class="dib">
  72. <span class="icon iconfont">&#xe6c4;</span>
  73. <div class="name">measure-filled</div>
  74. <div class="code-name">&amp;#xe6c4;</div>
  75. </li>
  76. <li class="dib">
  77. <span class="icon iconfont">&#xe6c6;</span>
  78. <div class="name">measure-angle</div>
  79. <div class="code-name">&amp;#xe6c6;</div>
  80. </li>
  81. <li class="dib">
  82. <span class="icon iconfont">&#xe6ca;</span>
  83. <div class="name">measure-distance</div>
  84. <div class="code-name">&amp;#xe6ca;</div>
  85. </li>
  86. <li class="dib">
  87. <span class="icon iconfont">&#xe6cb;</span>
  88. <div class="name">weather control-filled</div>
  89. <div class="code-name">&amp;#xe6cb;</div>
  90. </li>
  91. <li class="dib">
  92. <span class="icon iconfont">&#xe6cc;</span>
  93. <div class="name">configuration</div>
  94. <div class="code-name">&amp;#xe6cc;</div>
  95. </li>
  96. <li class="dib">
  97. <span class="icon iconfont">&#xe71f;</span>
  98. <div class="name">cloud download-filled</div>
  99. <div class="code-name">&amp;#xe71f;</div>
  100. </li>
  101. <li class="dib">
  102. <span class="icon iconfont">&#xe721;</span>
  103. <div class="name">cloud upload-filled</div>
  104. <div class="code-name">&amp;#xe721;</div>
  105. </li>
  106. <li class="dib">
  107. <span class="icon iconfont">&#xe786;</span>
  108. <div class="name">phase-review</div>
  109. <div class="code-name">&amp;#xe786;</div>
  110. </li>
  111. <li class="dib">
  112. <span class="icon iconfont">&#xe791;</span>
  113. <div class="name">data-space planning</div>
  114. <div class="code-name">&amp;#xe791;</div>
  115. </li>
  116. </ul>
  117. <div class="article markdown">
  118. <h2 id="unicode-">Unicode 引用</h2>
  119. <hr>
  120. <p>Unicode 是字体在网页端最原始的应用方式,特点是:</p>
  121. <ul>
  122. <li>支持按字体的方式去动态调整图标大小,颜色等等。</li>
  123. <li>默认情况下不支持多色,直接添加多色图标会自动去色。</li>
  124. </ul>
  125. <blockquote>
  126. <p>注意:新版 iconfont 支持两种方式引用多色图标:SVG symbol 引用方式和彩色字体图标模式。(使用彩色字体图标需要在「编辑项目」中开启「彩色」选项后并重新生成。)</p>
  127. </blockquote>
  128. <p>Unicode 使用步骤如下:</p>
  129. <h3 id="-font-face">第一步:拷贝项目下面生成的 <code>@font-face</code></h3>
  130. <pre><code class="language-css"
  131. >@font-face {
  132. font-family: 'iconfont';
  133. src: url('iconfont.woff2?t=1620285948639') format('woff2'),
  134. url('iconfont.woff?t=1620285948639') format('woff'),
  135. url('iconfont.ttf?t=1620285948639') format('truetype');
  136. }
  137. </code></pre>
  138. <h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
  139. <pre><code class="language-css"
  140. >.iconfont {
  141. font-family: "iconfont" !important;
  142. font-size: 16px;
  143. font-style: normal;
  144. -webkit-font-smoothing: antialiased;
  145. -moz-osx-font-smoothing: grayscale;
  146. }
  147. </code></pre>
  148. <h3 id="-">第三步:挑选相应图标并获取字体编码,应用于页面</h3>
  149. <pre>
  150. <code class="language-html"
  151. >&lt;span class="iconfont"&gt;&amp;#x33;&lt;/span&gt;
  152. </code></pre>
  153. <blockquote>
  154. <p>"iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。</p>
  155. </blockquote>
  156. </div>
  157. </div>
  158. <div class="content font-class">
  159. <ul class="icon_lists dib-box">
  160. <li class="dib">
  161. <span class="icon iconfont icon-clip-plane"></span>
  162. <div class="name">
  163. cutting
  164. </div>
  165. <div class="code-name">.icon-clip-plane
  166. </div>
  167. </li>
  168. <li class="dib">
  169. <span class="icon iconfont icon-clip-box"></span>
  170. <div class="name">
  171. model & plane-overlay
  172. </div>
  173. <div class="code-name">.icon-clip-box
  174. </div>
  175. </li>
  176. <li class="dib">
  177. <span class="icon iconfont icon-firstview-filled"></span>
  178. <div class="name">
  179. first view-filled
  180. </div>
  181. <div class="code-name">.icon-firstview-filled
  182. </div>
  183. </li>
  184. <li class="dib">
  185. <span class="icon iconfont icon-measure-area"></span>
  186. <div class="name">
  187. measure-area
  188. </div>
  189. <div class="code-name">.icon-measure-area
  190. </div>
  191. </li>
  192. <li class="dib">
  193. <span class="icon iconfont icon-measure-filled"></span>
  194. <div class="name">
  195. measure-filled
  196. </div>
  197. <div class="code-name">.icon-measure-filled
  198. </div>
  199. </li>
  200. <li class="dib">
  201. <span class="icon iconfont icon-measure-angle"></span>
  202. <div class="name">
  203. measure-angle
  204. </div>
  205. <div class="code-name">.icon-measure-angle
  206. </div>
  207. </li>
  208. <li class="dib">
  209. <span class="icon iconfont icon-measure-distance"></span>
  210. <div class="name">
  211. measure-distance
  212. </div>
  213. <div class="code-name">.icon-measure-distance
  214. </div>
  215. </li>
  216. <li class="dib">
  217. <span class="icon iconfont icon-weathercontrol-filled"></span>
  218. <div class="name">
  219. weather control-filled
  220. </div>
  221. <div class="code-name">.icon-weathercontrol-filled
  222. </div>
  223. </li>
  224. <li class="dib">
  225. <span class="icon iconfont icon-configuration"></span>
  226. <div class="name">
  227. configuration
  228. </div>
  229. <div class="code-name">.icon-configuration
  230. </div>
  231. </li>
  232. <li class="dib">
  233. <span class="icon iconfont icon-clouddownload-filled"></span>
  234. <div class="name">
  235. cloud download-filled
  236. </div>
  237. <div class="code-name">.icon-clouddownload-filled
  238. </div>
  239. </li>
  240. <li class="dib">
  241. <span class="icon iconfont icon-cloudupload-filled"></span>
  242. <div class="name">
  243. cloud upload-filled
  244. </div>
  245. <div class="code-name">.icon-cloudupload-filled
  246. </div>
  247. </li>
  248. <li class="dib">
  249. <span class="icon iconfont icon-phase-review"></span>
  250. <div class="name">
  251. phase-review
  252. </div>
  253. <div class="code-name">.icon-phase-review
  254. </div>
  255. </li>
  256. <li class="dib">
  257. <span class="icon iconfont icon-data-spaceplanning"></span>
  258. <div class="name">
  259. data-space planning
  260. </div>
  261. <div class="code-name">.icon-data-spaceplanning
  262. </div>
  263. </li>
  264. </ul>
  265. <div class="article markdown">
  266. <h2 id="font-class-">font-class 引用</h2>
  267. <hr>
  268. <p>font-class 是 Unicode 使用方式的一种变种,主要是解决 Unicode 书写不直观,语意不明确的问题。</p>
  269. <p>与 Unicode 使用方式相比,具有如下特点:</p>
  270. <ul>
  271. <li>相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。</li>
  272. <li>因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。</li>
  273. </ul>
  274. <p>使用步骤如下:</p>
  275. <h3 id="-fontclass-">第一步:引入项目下面生成的 fontclass 代码:</h3>
  276. <pre><code class="language-html">&lt;link rel="stylesheet" href="./iconfont.css"&gt;
  277. </code></pre>
  278. <h3 id="-">第二步:挑选相应图标并获取类名,应用于页面:</h3>
  279. <pre><code class="language-html">&lt;span class="iconfont icon-xxx"&gt;&lt;/span&gt;
  280. </code></pre>
  281. <blockquote>
  282. <p>"
  283. iconfont" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。</p>
  284. </blockquote>
  285. </div>
  286. </div>
  287. <div class="content symbol">
  288. <ul class="icon_lists dib-box">
  289. <li class="dib">
  290. <svg class="icon svg-icon" aria-hidden="true">
  291. <use xlink:href="#icon-clip-plane"></use>
  292. </svg>
  293. <div class="name">cutting</div>
  294. <div class="code-name">#icon-clip-plane</div>
  295. </li>
  296. <li class="dib">
  297. <svg class="icon svg-icon" aria-hidden="true">
  298. <use xlink:href="#icon-clip-box"></use>
  299. </svg>
  300. <div class="name">model & plane-overlay</div>
  301. <div class="code-name">#icon-clip-box</div>
  302. </li>
  303. <li class="dib">
  304. <svg class="icon svg-icon" aria-hidden="true">
  305. <use xlink:href="#icon-firstview-filled"></use>
  306. </svg>
  307. <div class="name">first view-filled</div>
  308. <div class="code-name">#icon-firstview-filled</div>
  309. </li>
  310. <li class="dib">
  311. <svg class="icon svg-icon" aria-hidden="true">
  312. <use xlink:href="#icon-measure-area"></use>
  313. </svg>
  314. <div class="name">measure-area</div>
  315. <div class="code-name">#icon-measure-area</div>
  316. </li>
  317. <li class="dib">
  318. <svg class="icon svg-icon" aria-hidden="true">
  319. <use xlink:href="#icon-measure-filled"></use>
  320. </svg>
  321. <div class="name">measure-filled</div>
  322. <div class="code-name">#icon-measure-filled</div>
  323. </li>
  324. <li class="dib">
  325. <svg class="icon svg-icon" aria-hidden="true">
  326. <use xlink:href="#icon-measure-angle"></use>
  327. </svg>
  328. <div class="name">measure-angle</div>
  329. <div class="code-name">#icon-measure-angle</div>
  330. </li>
  331. <li class="dib">
  332. <svg class="icon svg-icon" aria-hidden="true">
  333. <use xlink:href="#icon-measure-distance"></use>
  334. </svg>
  335. <div class="name">measure-distance</div>
  336. <div class="code-name">#icon-measure-distance</div>
  337. </li>
  338. <li class="dib">
  339. <svg class="icon svg-icon" aria-hidden="true">
  340. <use xlink:href="#icon-weathercontrol-filled"></use>
  341. </svg>
  342. <div class="name">weather control-filled</div>
  343. <div class="code-name">#icon-weathercontrol-filled</div>
  344. </li>
  345. <li class="dib">
  346. <svg class="icon svg-icon" aria-hidden="true">
  347. <use xlink:href="#icon-configuration"></use>
  348. </svg>
  349. <div class="name">configuration</div>
  350. <div class="code-name">#icon-configuration</div>
  351. </li>
  352. <li class="dib">
  353. <svg class="icon svg-icon" aria-hidden="true">
  354. <use xlink:href="#icon-clouddownload-filled"></use>
  355. </svg>
  356. <div class="name">cloud download-filled</div>
  357. <div class="code-name">#icon-clouddownload-filled</div>
  358. </li>
  359. <li class="dib">
  360. <svg class="icon svg-icon" aria-hidden="true">
  361. <use xlink:href="#icon-cloudupload-filled"></use>
  362. </svg>
  363. <div class="name">cloud upload-filled</div>
  364. <div class="code-name">#icon-cloudupload-filled</div>
  365. </li>
  366. <li class="dib">
  367. <svg class="icon svg-icon" aria-hidden="true">
  368. <use xlink:href="#icon-phase-review"></use>
  369. </svg>
  370. <div class="name">phase-review</div>
  371. <div class="code-name">#icon-phase-review</div>
  372. </li>
  373. <li class="dib">
  374. <svg class="icon svg-icon" aria-hidden="true">
  375. <use xlink:href="#icon-data-spaceplanning"></use>
  376. </svg>
  377. <div class="name">data-space planning</div>
  378. <div class="code-name">#icon-data-spaceplanning</div>
  379. </li>
  380. </ul>
  381. <div class="article markdown">
  382. <h2 id="symbol-">Symbol 引用</h2>
  383. <hr>
  384. <p>这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇<a href="">文章</a>
  385. 这种用法其实是做了一个 SVG 的集合,与另外两种相比具有如下特点:</p>
  386. <ul>
  387. <li>支持多色图标了,不再受单色限制。</li>
  388. <li>通过一些技巧,支持像字体那样,通过 <code>font-size</code>, <code>color</code> 来调整样式。</li>
  389. <li>兼容性较差,支持 IE9+,及现代浏览器。</li>
  390. <li>浏览器渲染 SVG 的性能一般,还不如 png。</li>
  391. </ul>
  392. <p>使用步骤如下:</p>
  393. <h3 id="-symbol-">第一步:引入项目下面生成的 symbol 代码:</h3>
  394. <pre><code class="language-html">&lt;script src="./iconfont.js"&gt;&lt;/script&gt;
  395. </code></pre>
  396. <h3 id="-css-">第二步:加入通用 CSS 代码(引入一次就行):</h3>
  397. <pre><code class="language-html">&lt;style&gt;
  398. .icon {
  399. width: 1em;
  400. height: 1em;
  401. vertical-align: -0.15em;
  402. fill: currentColor;
  403. overflow: hidden;
  404. }
  405. &lt;/style&gt;
  406. </code></pre>
  407. <h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3>
  408. <pre><code class="language-html">&lt;svg class="icon" aria-hidden="true"&gt;
  409. &lt;use xlink:href="#icon-xxx"&gt;&lt;/use&gt;
  410. &lt;/svg&gt;
  411. </code></pre>
  412. </div>
  413. </div>
  414. </div>
  415. </div>
  416. <script>
  417. $(document).ready(function () {
  418. $('.tab-container .content:first').show()
  419. $('#tabs li').click(function (e) {
  420. var tabContent = $('.tab-container .content')
  421. var index = $(this).index()
  422. if ($(this).hasClass('active')) {
  423. return
  424. } else {
  425. $('#tabs li').removeClass('active')
  426. $(this).addClass('active')
  427. tabContent.hide().eq(index).fadeIn()
  428. }
  429. })
  430. })
  431. </script>
  432. </body>
  433. </html>