怎么通过vscode去使用iconfont里面的字体图标
时间: 2023-08-30 12:05:10 浏览: 48
要在 VSCode 中使用 Iconfont 的字体图标,需要先通过 Iconfont 官网下载相应的字体文件。然后,将字体文件保存到项目中的某个目录下,例如 `src/fonts`。
接下来,在样式文件中引入字体文件,例如:
```css
@font-face {
font-family: 'iconfont';
src: url('./fonts/iconfont.eot');
src: url('./fonts/iconfont.eot?#iefix') format('embedded-opentype'),
url('./fonts/iconfont.woff2') format('woff2'),
url('./fonts/iconfont.woff') format('woff'),
url('./fonts/iconfont.ttf') format('truetype'),
url('./fonts/iconfont.svg#iconfont') format('svg');
font-weight: normal;
font-style: normal;
}
.iconfont {
font-family: 'iconfont' !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
```
在 HTML 文件中使用相应的图标,例如:
```html
<i class="iconfont"></i>
```
其中,`` 是图标的 Unicode 码。
这样,在 VSCode 中使用 Iconfont 的字体图标就完成了。