css - 一些 Icomoon 图标不会显示

标签 css icons icon-fonts

我在应用程序中使用 Icomoon - 我遇到了一些图标无法显示的问题。我已经通过 Icomoon App 下载了所有图标,这是最新版本 - 所有 450 个都已选中。

我已经在没有其他 CSS 的空白页面上进行了尝试,但它们仍然无法正常工作,以防是我的应用程序中的某些 CSS 导致了它。

<link rel="stylesheet" type="text/css" href="/css/icons/icomoon/style.css" media="screen" />

<i class="icon-user"></i> User
<i class="icon-bars"></i> Bars
<i class="icon-search"><i> Search

在上面,条形图显示正常,但用户和搜索显示不正常。

这是我的 style.css 文件(已截断):

@font-face
{
    font-family: 'IcoMoon';
    src:url('fonts/icomoon.eot');
    src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),
        url('fonts/icomoon.svg#IcoMoon') format('svg'),
        url('fonts/icomoon.woff') format('woff'),
        url('fonts/icomoon.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

[class^="icon-"], 
[class*=" icon-"]
{
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
}

[class^="icon-"]:before, 
[class*=" icon-"]:before
{
    font-family: 'IcoMoon';
    font-weight: normal;
    font-style: normal;
    speak: none;
    -webkit-font-smoothing: antialiased;
}

.icon-users:before {
    content: "\92";
}
.icon-bars:before {
    content: "\b8";
}
.icon-search:before {
    content: "\a0";
}

如果我打开 icomoon.svg(我唯一可以“编辑”的文件),那么 92 和 a0 都在那里:

<glyph unicode="&#x92;" d="M734.994 154.626c-18.952 2.988-19.384 54.654-19.384 54.654s55.688 54.656 67.824 128.152c32.652 0 52.814 78.138 20.164 105.628 1.362 28.94 41.968 227.176-163.598 227.176-205.564 0-164.958-198.236-163.598-227.176-32.654-27.49-12.488-105.628 20.162-105.628 12.134-73.496 67.826-128.152 67.826-128.152s-0.432-51.666-19.384-54.654c-61.048-9.632-289.006-109.316-289.006-218.626h768c0 109.31-227.958 208.994-289.006 218.626zM344.054 137.19c44.094 27.15 97.626 52.308 141.538 67.424-15.752 22.432-33.294 52.936-44.33 89.062-15.406 12.566-27.944 30.532-35.998 52.602-8.066 22.104-11.122 46.852-8.608 69.684 1.804 16.392 6.478 31.666 13.65 45.088-4.35 46.586-7.414 138.034 52.448 204.732 23.214 25.866 52.556 44.46 87.7 55.686-6.274 64.76-39.16 140.77-166.454 140.77-205.564 0-164.958-198.236-163.598-227.176-32.654-27.49-12.488-105.628 20.162-105.628 12.134-73.496 67.826-128.152 67.826-128.152s-0.432-51.666-19.384-54.654c-61.048-9.634-289.006-109.318-289.006-218.628h329.596c4.71 3.074 9.506 6.14 14.458 9.19z" />

<glyph unicode="&#xa0;" d="M992.262 88.604l-242.552 206.294c-25.074 22.566-51.89 32.926-73.552 31.926 57.256 67.068 91.842 154.078 91.842 249.176 0 212.078-171.922 384-384 384-212.076 0-384-171.922-384-384 0-212.078 171.922-384 384-384 95.098 0 182.108 34.586 249.176 91.844-1-21.662 9.36-48.478 31.926-73.552l206.294-242.552c35.322-39.246 93.022-42.554 128.22-7.356s31.892 92.898-7.354 128.22zM384 320c-141.384 0-256 114.616-256 256s114.616 256 256 256 256-114.616 256-256-114.614-256-256-256z" />

此外,在 icomoon 应用程序创建的演示 html 文件中,从 7f(下载)到 a0(搜索)的所有图标都显示为空白 - 我尝试使用的两个图标都属于这个范围。

知道为什么有些会显示而有些不会显示吗?

最佳答案

我在 IE11 和 edge 中遇到的问题是显示的是大写变体而不是小写图标。这是因为 IE11/edge 在处理 css 应用字符时忽略了大小写,只搜索字体文件中的第一个“匹配项”。

正如您在这张图片中看到的,小写字母“g”映射到垃圾桶图标,而大写字母“G”映射到播放图标。 IE11 和 edge 错误地使用了第一个大写变体。

您可以使用 font forge 检查您的字体文件来测试这个可能的原因。并通过在图标本身的 CSS 中显式声明“文本转换:小写/大写”,看看是否可以修复它。

enter image description here

为了最终解决这个问题,我从图标字体中删除了所有大写字母并将所有内容重新映射到 other unicode characters一切都按预期进行。我在这篇文章中找到了我的解决方案:Icon font behaving strangely in IE11

关于css - 一些 Icomoon 图标不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20571588/

相关文章:

javascript - 在一个文件中下载 css 和 js(包)

基于列表项的文本值的 css 样式

css - IE7 中的图标字体

html - 如果我不支持 IE6/7,使用 <button> 而不是 &lt;input type ="submit"> 有什么缺点吗?

javascript - 关闭图标上的汉堡菜单,onclick

javascript - 隐藏计算器的所有按钮

java - Google Play - 图标无效

java - 在 Android 上添加自定义字体时崩溃

android - 如何更改android中字体图标的颜色

javascript - CSS 首选高度和最大高度