123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8"/>
- <title>IconFont</title>
- <link rel="stylesheet" href="demo.css">
- <script src="iconfont.js"></script>
- <style type="text/css">
- .icon {
- /* 通过设置 font-size 来改变图标大小 */
- width: 1em; height: 1em;
- /* 图标和文字相邻时,垂直对齐 */
- vertical-align: -0.15em;
- /* 通过设置 color 来改变 SVG 的颜色/fill */
- fill: currentColor;
- /* path 和 stroke 溢出 viewBox 部分在 IE 下会显示
- normalize.css 中也包含这行 */
- overflow: hidden;
- }
- </style>
- </head>
- <body>
- <div class="main markdown">
- <h1>IconFont 图标</h1>
- <ul class="icon_lists clear">
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-msnui-poweroff"></use>
- </svg>
- <div class="name">关机</div>
- <div class="fontclass">#icon-msnui-poweroff</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-close"></use>
- </svg>
- <div class="name">close</div>
- <div class="fontclass">#icon-close</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-shanchu"></use>
- </svg>
- <div class="name">删除</div>
- <div class="fontclass">#icon-shanchu</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-quanping"></use>
- </svg>
- <div class="name">全屏</div>
- <div class="fontclass">#icon-quanping</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-shanchu1"></use>
- </svg>
- <div class="name">删除</div>
- <div class="fontclass">#icon-shanchu1</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_huabanfuben"></use>
- </svg>
- <div class="name">未标题-1_画板 1 副本 6</div>
- <div class="fontclass">#icon-weibiaoti-_huabanfuben</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_huabanfuben1"></use>
- </svg>
- <div class="name">未标题-1_画板 1 副本 7</div>
- <div class="fontclass">#icon-weibiaoti-_huabanfuben1</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_huabanfuben2"></use>
- </svg>
- <div class="name">未标题-1_画板 1 副本 11</div>
- <div class="fontclass">#icon-weibiaoti-_huabanfuben2</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_huabanfuben3"></use>
- </svg>
- <div class="name">未标题-1_画板 1 副本 10</div>
- <div class="fontclass">#icon-weibiaoti-_huabanfuben3</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_huabanfuben4"></use>
- </svg>
- <div class="name">未标题-1_画板 1 副本 9</div>
- <div class="fontclass">#icon-weibiaoti-_huabanfuben4</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_huabanfuben5"></use>
- </svg>
- <div class="name">未标题-1_画板 1 副本 8</div>
- <div class="fontclass">#icon-weibiaoti-_huabanfuben5</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_Time-active"></use>
- </svg>
- <div class="name">未标题-1_Time-active</div>
- <div class="fontclass">#icon-weibiaoti-_Time-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_b-active"></use>
- </svg>
- <div class="name">未标题-1_b-active</div>
- <div class="fontclass">#icon-weibiaoti-_b-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_A-active"></use>
- </svg>
- <div class="name">未标题-1_A-active</div>
- <div class="fontclass">#icon-weibiaoti-_A-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_Add-active"></use>
- </svg>
- <div class="name">未标题-1_Add-active</div>
- <div class="fontclass">#icon-weibiaoti-_Add-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_center-active"></use>
- </svg>
- <div class="name">未标题-1_center-active</div>
- <div class="fontclass">#icon-weibiaoti-_center-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_life-active"></use>
- </svg>
- <div class="name">未标题-1_life-active</div>
- <div class="fontclass">#icon-weibiaoti-_life-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_youxu-active"></use>
- </svg>
- <div class="name">未标题-1_youxu-active</div>
- <div class="fontclass">#icon-weibiaoti-_youxu-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_right-active"></use>
- </svg>
- <div class="name">未标题-1_right-active</div>
- <div class="fontclass">#icon-weibiaoti-_right-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_U-active"></use>
- </svg>
- <div class="name">未标题-1_U-active</div>
- <div class="fontclass">#icon-weibiaoti-_U-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_wuxu-active"></use>
- </svg>
- <div class="name">未标题-1_wuxu-active</div>
- <div class="fontclass">#icon-weibiaoti-_wuxu-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_Pic-active"></use>
- </svg>
- <div class="name">未标题-1_Pic-active</div>
- <div class="fontclass">#icon-weibiaoti-_Pic-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-weibiaoti-_I-active"></use>
- </svg>
- <div class="name">未标题-1_I-active</div>
- <div class="fontclass">#icon-weibiaoti-_I-active</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-hebing"></use>
- </svg>
- <div class="name">合并 (1)</div>
- <div class="fontclass">#icon-hebing</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-caijian"></use>
- </svg>
- <div class="name">裁剪</div>
- <div class="fontclass">#icon-caijian</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-jianqie"></use>
- </svg>
- <div class="name">剪切</div>
- <div class="fontclass">#icon-jianqie</div>
- </li>
-
- <li>
- <svg class="icon" aria-hidden="true">
- <use xlink:href="#icon-xunhuan"></use>
- </svg>
- <div class="name">循环2</div>
- <div class="fontclass">#icon-xunhuan</div>
- </li>
-
- </ul>
- <h2 id="symbol-">symbol引用</h2>
- <hr>
- <p>这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇<a href="">文章</a>
- 这种用法其实是做了一个svg的集合,与另外两种相比具有如下特点:</p>
- <ul>
- <li>支持多色图标了,不再受单色限制。</li>
- <li>通过一些技巧,支持像字体那样,通过<code>font-size</code>,<code>color</code>来调整样式。</li>
- <li>兼容性较差,支持 ie9+,及现代浏览器。</li>
- <li>浏览器渲染svg的性能一般,还不如png。</li>
- </ul>
- <p>使用步骤如下:</p>
- <h3 id="-symbol-">第一步:引入项目下面生成的symbol代码:</h3>
- <pre><code class="lang-js hljs javascript"><span class="hljs-comment"><script src="./iconfont.js"></script></span></code></pre>
- <h3 id="-css-">第二步:加入通用css代码(引入一次就行):</h3>
- <pre><code class="lang-js hljs javascript"><style type=<span class="hljs-string">"text/css"</span>>
- .icon {
- width: <span class="hljs-number">1</span>em; height: <span class="hljs-number">1</span>em;
- vertical-align: <span class="hljs-number">-0.15</span>em;
- fill: currentColor;
- overflow: hidden;
- }
- <<span class="hljs-regexp">/style></span></code></pre>
- <h3 id="-">第三步:挑选相应图标并获取类名,应用于页面:</h3>
- <pre><code class="lang-js hljs javascript"><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>><span class="xml"><span class="hljs-tag">
- <<span class="hljs-name">use</span> <span class="hljs-attr">xlink:href</span>=<span class="hljs-string">"#icon-xxx"</span>></span><span class="hljs-tag"></<span class="hljs-name">use</span>></span>
- </span><<span class="hljs-regexp">/svg>
- </span></code></pre>
- </div>
- </body>
- </html>
|