demo_symbol.html
14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!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="#i-zhizhen1"></use>
</svg>
<div class="name">指针</div>
<div class="fontclass">#i-zhizhen1</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-msnui-close-fat"></use>
</svg>
<div class="name">关闭</div>
<div class="fontclass">#i-msnui-close-fat</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-close"></use>
</svg>
<div class="name">close</div>
<div class="fontclass">#i-close</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-wenjiantianjia"></use>
</svg>
<div class="name">文件添加</div>
<div class="fontclass">#i-wenjiantianjia</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-tag"></use>
</svg>
<div class="name">tag</div>
<div class="fontclass">#i-tag</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-conowredo"></use>
</svg>
<div class="name">conow-redo</div>
<div class="fontclass">#i-conowredo</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-conowrevoke"></use>
</svg>
<div class="name">conow-revoke</div>
<div class="fontclass">#i-conowrevoke</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-baocun"></use>
</svg>
<div class="name">保存</div>
<div class="fontclass">#i-baocun</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-refresh"></use>
</svg>
<div class="name">Refresh</div>
<div class="fontclass">#i-refresh</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-youxiashixin"></use>
</svg>
<div class="name">右下-实心</div>
<div class="fontclass">#i-youxiashixin</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-paizhaoanniu"></use>
</svg>
<div class="name">拍照按钮</div>
<div class="fontclass">#i-paizhaoanniu</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-huizhang"></use>
</svg>
<div class="name">徽章</div>
<div class="fontclass">#i-huizhang</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-hrgongzuotai"></use>
</svg>
<div class="name">hr工作台</div>
<div class="fontclass">#i-hrgongzuotai</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-tingzhi-copy"></use>
</svg>
<div class="name">停止</div>
<div class="fontclass">#i-tingzhi-copy</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-wenjianjia"></use>
</svg>
<div class="name">文件夹</div>
<div class="fontclass">#i-wenjianjia</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-webtubiaoku08"></use>
</svg>
<div class="name">声音</div>
<div class="fontclass">#i-webtubiaoku08</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-database"></use>
</svg>
<div class="name">数据库</div>
<div class="fontclass">#i-database</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-chajian1"></use>
</svg>
<div class="name">插件 (1)</div>
<div class="fontclass">#i-chajian1</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-caidan"></use>
</svg>
<div class="name">菜单</div>
<div class="fontclass">#i-caidan</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-wangluo"></use>
</svg>
<div class="name">网络</div>
<div class="fontclass">#i-wangluo</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-dayin"></use>
</svg>
<div class="name">打印</div>
<div class="fontclass">#i-dayin</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-user"></use>
</svg>
<div class="name">用户</div>
<div class="fontclass">#i-user</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-kaishi"></use>
</svg>
<div class="name">开始</div>
<div class="fontclass">#i-kaishi</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-hebing"></use>
</svg>
<div class="name">合并</div>
<div class="fontclass">#i-hebing</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-liaotian"></use>
</svg>
<div class="name">聊天</div>
<div class="fontclass">#i-liaotian</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-dingshi"></use>
</svg>
<div class="name">定时</div>
<div class="fontclass">#i-dingshi</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-xiejiantou"></use>
</svg>
<div class="name">斜箭头</div>
<div class="fontclass">#i-xiejiantou</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-peizhi"></use>
</svg>
<div class="name">配置</div>
<div class="fontclass">#i-peizhi</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-xiangmuzuhe"></use>
</svg>
<div class="name">项目组合</div>
<div class="fontclass">#i-xiangmuzuhe</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-xitongcanshupeizhi"></use>
</svg>
<div class="name">系统参数配置</div>
<div class="fontclass">#i-xitongcanshupeizhi</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-qukuai"></use>
</svg>
<div class="name">区块</div>
<div class="fontclass">#i-qukuai</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-fenzhi"></use>
</svg>
<div class="name">分支</div>
<div class="fontclass">#i-fenzhi</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-icon-test"></use>
</svg>
<div class="name">01</div>
<div class="fontclass">#i-icon-test</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-icon-test1"></use>
</svg>
<div class="name">02</div>
<div class="fontclass">#i-icon-test1</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-xiaoxuxian"></use>
</svg>
<div class="name">小虚线</div>
<div class="fontclass">#i-xiaoxuxian</div>
</li>
<li>
<svg class="icon" aria-hidden="true">
<use xlink:href="#i-jianchagongjuzhixian"></use>
</svg>
<div class="name">检查工具 直线</div>
<div class="fontclass">#i-jianchagongjuzhixian</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">"#i-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>