gpt4 book ai didi

css - 未加载自定义图标字体

转载 作者:太空宇宙 更新时间:2023-11-03 23:27:23 26 4
gpt4 key购买 nike

使用 gulp-iconfont-css,我正在尝试将 Material Design svg 编译成字体。这是我的 Gulpfile.js 的一部分:

gulp.task('iconfont', function(){
gulp.src(paths.svg)
.pipe(iconfontCss({
fontName: 'material-design', // required
path: './www/sass/templates/_icons.scss',
targetPath: '../sass/_icons.scss',
fontPath: '/fonts/'
})).pipe(iconfont({
fontName: 'material-design', // required
}))
.pipe(gulp.dest('./www/fonts/'));
});

现在我的模板:

@font-face {
font-family: "<%= fontName %>";
src: url('<%= fontPath %><%= fontName %>.eot');
src: url('<%= fontPath %><%= fontName %>.eot?#iefix') format('eot'),
url('<%= fontPath %><%= fontName %>.woff') format('woff'),
url('<%= fontPath %><%= fontName %>.ttf') format('truetype'),
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');
}

.icon:before {
font-family: "<%= fontName %>";
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-style: normal;
font-variant: normal;
font-weight: normal;
// speak: none; // only necessary if not using the private unicode range (firstGlyph option)
text-decoration: none;
text-transform: none;
}

<% _.each(glyphs, function(glyph) { %>
<% var array = glyph.fileName.split('_') %>
.icon-<%= array.slice(1, array.length - 1).join('-') %>:before {
content: "\<%= glyph.codePoint %>";
}
<% }); %>

问题:我的图标没有加载 当我创建这样的元素时:

 <i class="icon-send"></i>

我什么都没看到。并且字体永远不会下载到服务器上(在网络日志中)。此外,图标用不同的值定义了两次。摘录:

@font-face {
font-family: "material-design";
src: url('/fonts/material-design.eot');
src: url('/fonts/material-design.eot?#iefix') format('eot'), url('/fonts/material-design.woff') format('woff'), url('/fonts/material-design.ttf') format('truetype'), url('/fonts/material-design.svg#material-design') format('svg'); }

.icon:before {
font-family: "material-design";
...
text-transform: none; }

.icon-3d-rotation:before {
content: "\E001"; }

.icon-3d-rotation:before {
content: "\E002"; }

.icon-accessibility:before {
content: "\E003"; }

.icon-accessibility:before {
content: "\E004"; }

最佳答案

可能是因为没有设置字体?字体系列在“图标”类中定义,但您没有指定。如果您改用以下内容会怎样?

<i class="icon icon-send"></i>

关于css - 未加载自定义图标字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26443105/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com