iconfont.js
时间: 2024-08-17 07:02:08 浏览: 76
IconFont.js 是一种用于在网页上加载和显示自定义字体图标的小型 JavaScript 库。它通常与 CSS 和 HTML 结合使用,以便在项目中轻松集成预定义的图标集,如阿里巴巴矢量图库(如 '@ant-design/icons')。
以下是基本的使用示例:
1. **引入 IconFont.js**[^4]:
```html
<script src="path/to/iconfont.min.js"></script>
```
2. **在CSS中定义图标样式**[^5]:
```css
@font-face {
font-family: 'your_font_family';
src: url('path/to/font.eot'); /* IE9支持 */
src: url('path/to/font.eot?#iefix') format('embedded-opentype'), /* IE6-IE8支持 */
url('path/to/font.woff2') format('woff2'), /* Modern Browsers */
url('path/to/font.woff') format('woff'), /* Modern Browsers */
url('path/to/font.ttf') format('truetype'), /* Safari, Android, iOS */
url('path/to/font.svg#svg_name') format('svg'); /* Legacy iOS */
}
.your-class {
font-family: 'your_font_family';
font-style: normal;
font-weight: normal;
speak: none;
}
```
3. **在HTML中使用图标**[^4]:
```html
<i class="your-icon-class">你好,世界</i>
```
其中 `.your-icon-class` 是从你的字体文件中选择的特定图标类名。
阅读全文
相关推荐


















