Bootstrap 3 Glyphicons无效

sco*_*ord 351 glyphicons twitter-bootstrap-3

我下载了bootstrap 3.0,无法让glyphicons工作.我收到某种"E003"错误.任何想法为什么会这样?我在本地和网上尝试过,我仍然遇到同样的问题.

Jef*_*eff 474

我遇到了同样的问题,除了本页隐藏的评论外,找不到任何相关信息.根据Chrome,我的字体文件加载得很好,但图标显示不正常.我正在给这个答案,所以它有望帮助别人.

我从Bootstrap 3的自定义工具下载的字体文件出了问题.要获取正确的字体,请转到Bootstrap主页并下载完整的.zip文件.从那里提取四个字体文件到你的字体目录,一切都应该工作.

  • 正确答案!自定义程序中的字体文件已损坏! (10认同)
  • 交换getbootstrap.com主页的bootstrap-3.0.0中包含的字体文件.谢谢你的提示! (5认同)
  • 我想添加我的“我也是”的回应,并说在浪费了几个小时的努力之后,我几乎愤怒地退出了我的职业生涯,我找到了这个答案,现在我又可以使用 glyphicons 了。谢谢!! (2认同)
  • 我迫不及待地想成为所有成功人士的一份子,但现在尽管已经尝试了 Stack 的几乎所有解决方案和答案,我仍然无法看到图标。我什至尝试启动一个全新的 MVC 5 应用程序并使用 Nuget 安装引导程序最新版本 3.3.7,该版本正确安装了所有文件夹,并且浏览器调试器工具中没有显示 404 或任何告诉我字体未加载的内容,并且我可以告诉你,跨度的代码是完美的,所以我的问题在哪里。老实说我不知道​​。我测试了所有浏览器,没有一个显示图标 (2认同)

use*_*702 231

读者注意:请务必阅读@ user2261073的评论@ Jeff关于定制器中的错误的答案.这可能是导致问题的原因.


字体文件未正确加载.检查文件是否在预期位置.

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
}
Run Code Online (Sandbox Code Playgroud)

如Daniel所示,它也可能是一个mimetype问题.Chrome的开发工具在网络标签中显示已下载的字体:

chrome网络选项卡字体下载

  • 看起来我发现了问题.引导程序定制器似乎发送的大小不同于示例附带的整个引导程序包内的字体.我替换了文件,现在一切正常.它很可能是bootstrap定制器中的一个错误?谁知道.我可以在某个地方报告,以便他们可以查看吗? (46认同)
  • 并且mimetypes已正确注册. (5认同)
  • ...虽然在我下载bootstrap.zip文件时文件应该就位,但我仍然需要仔细检查并且每个都已到位.我如何检查mimetypes注册(=?) (4认同)
  • @ user2261073您可以在GitHub项目上报告它.似乎已经有一个活跃的错误报告:https://github.com/twbs/bootstrap/issues/10008 (2认同)

D.R*_*ado 76

在我的情况下,我获得了404 字形 - 半身像 - regular.woff,以及移动浏览器上的非可见字形.

看起来对于woff的MIME类型存在一些混淆,不同浏览器接受多种MIME类型,但W3C说:

application/font-woff
Run Code Online (Sandbox Code Playgroud)

编辑:测试以下MIME类型后woff适用于当前所有浏览器:

application/x-font-woff
Run Code Online (Sandbox Code Playgroud)

编辑:此时最新版本的Bootstrap(3.3.5)使用与.woff初始结果相同的.woff2字体,W3C仍然定义规范,但目前MIME类型似乎是:

application/font-woff2
Run Code Online (Sandbox Code Playgroud)

  • 这向我指出了良好的方向,但它也给了我Chrome中的另一个警告......实际上MIME类型应该是:`application/x-font-woff`然后Firefox和Chrome终于都开心:) (17认同)

Cra*_*ste 54

- 如果您遵循最高评级的答案,它仍然无法正常工作:

Font文件夹必须与CSS文件夹位于同一级别.修复路径bootstrap.css 将无法正常工作.

Bootstrap.css必须完全像这样导航到Fonts文件夹:

@font-face {
    font-family: 'Glyphicons Halflings';

    src: url('../fonts/glyphicons-halflings-regular.eot');
    src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
Run Code Online (Sandbox Code Playgroud)

  • 我认为70%的Glyphicon不适合这种情况,很好的回答,我经常把bootstrap css文件放在css/bootstrap中.只需将它们移动到css,一切正常 (3认同)

小智 45

如果其他解决方案不起作用,您可能想尝试从外部源导入Glyphicons,而不是依靠Bootstrap为您做所有事情.去做这个:

您可以在HTML中执行此操作:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)

或CSS:

@import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css")
Run Code Online (Sandbox Code Playgroud)

感谢edsiofi来自这个主题:Bootstrap 3 Glyphicons CDN


sco*_*ord 21

我正在仔细阅读我的这个老问题,因为到目前为止我应该给出正确的答案,我在评论中给出了这一点,我认为我也值得赞扬.

问题在于,从bootstrap的自定义工具下载glyphicon字体文件与从bootstrap主页上找到的重定向下载glyphicon字体文件不同.那些正常工作的是可以从以下链接下载的那些:

http://getbootstrap.com/getting-started/#download
Run Code Online (Sandbox Code Playgroud)

任何有旧的自定义程序文件问题的人都应该覆盖上面链接中的字体.


Ant*_*cik 18

Azure网站缺少woff MIME配置.您必须在web.config中添加以下条目

<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension="woff" mimeType="application/font-woff" />
        </staticContent>
    </system.webServer>
</configuration> 
Run Code Online (Sandbox Code Playgroud)


Can*_*ner 16

如果有人在这里结束并使用Bootstrap> = v4.0:将删除glyphicon支持

发布说明中的相关部分:

删除了Glyphicons图标字体.如果您需要图标,一些选项是:

Glyphicons的上游版本

Octicons

字体很棒

资料来源:https://v4-alpha.getbootstrap.com/migration/#components

如果您想使用glyphicons,您需要单独下载.

我个人尝试过Font Awesome,它非常棒.添加图标类似于glypicon方式:

<i class="fas fa-chess"></i>
Run Code Online (Sandbox Code Playgroud)


小智 15

正如@Stijn所描述的那样,从中Bootstrap.css安装此软件包时,默认位置不正确Nuget.

将此部分更改为如下所示:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('Content/fonts/glyphicons-halflings-regular.eot');
  src: url('Content/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded- opentype'), url('Content/fonts/glyphicons-halflings-regular.woff') format('woff'), url('Content/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('Content/fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
}
Run Code Online (Sandbox Code Playgroud)


Ste*_*per 8

.woff默认情况下IIS不会服务器文件,所以在IIS中你需要<mimeMap>web.config文件中添加一个条目;

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
        </staticContent>
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)


Y. *_*gha 8

您可以添加这行代码并完成.

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
Run Code Online (Sandbox Code Playgroud)

谢谢.


小智 7

我修改了我的less variables.less文件我修改了变量

@icon-font-path:          "fonts/";    
Run Code Online (Sandbox Code Playgroud)

原来是

@icon-font-path:          "../fonts/"; 
Run Code Online (Sandbox Code Playgroud)

这引起了一个问题

  • 对于bootstrap-sass 3.2.0.1 gem,它似乎需要`$ icon-font-path:"/ assets/bootstrap /"`. (2认同)

pri*_*sen 6

这是由于bootstrap.css和bootstrap.min.css中的编码错误造成的.从Customizer下载Bootstrap 3.0时,缺少以下代码:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg');
}
Run Code Online (Sandbox Code Playgroud)

由于这是使用Glyphicons的主要代码,因此它不会起作用...

从完整包中下载css文件,将实现此代码.


Vic*_*cky 6

您的fonts目录中是否包含以下所有文件?

glyphicons-halflings-regular.eot
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff
Run Code Online (Sandbox Code Playgroud)

  • 但是,有些人在fonts文件夹中拥有所有这些文件,但如果未在IIS中注册mime类型woff,则仍然会收到此错误. (2认同)

Jo *_*Smo 6

这就是为什么图标没有显示给我的原因:

* {
    arial, sans-serif !important;
}
Run Code Online (Sandbox Code Playgroud)

在我删除了我的这一部分之后CSS,一切都按照它应有的方式进行.重要的是导致麻烦的那个.


TWi*_*Rob 5

另一个问题/解决方案可能是使用此Bootstrap 2.x代码:

<button class="btn" ng-click="open()"><i class="icon-calendar"></i></button>
Run Code Online (Sandbox Code Playgroud)

并在基于指南(.icon-* ---> .glyphicon .glyphicon-*)进行迁移时:

<button class="btn btn-default" ng-click="open()"><i class="glyphicon-calendar"></i></button>
Run Code Online (Sandbox Code Playgroud)

你忘了添加图标类(包含字体引用):

<button class="btn btn-default" ng-click="open()"><i class="glyphicon glyphicon-calendar"></i></button>
Run Code Online (Sandbox Code Playgroud)


Aar*_*ron 5

以下是为我修复它的原因.我在Firebug控制台中使用"错误的URI"错误.图标显示为E ###数字.我必须在我的'fonts'目录中添加一个.htaccess文件. <FilesMatch "\.(ttf|otf|eot|woff)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch> 可能重复:firefox上的可下载字体:不允许使用错误的URI或跨站点访问


Vic*_*ist 5

这是一个很长的拍摄,但这是我的情况,因为它已经不存在了.

如果您正在使用gulp-sass或者编辑来自SASS的Twitter Bootstrap grunt-sass.node-sass.确保您的节点模块是最新的,特别是如果您正在处理一个相当旧的项目.

事实证明,在某些时候,SASS指令@at-root用于@font-face字形图的定义,请参阅https://github.com/twbs/bootstrap-sass/blob/b01ab4942233bd7316a0634472e1243b13fb9f46/assets/stylesheets/bootstrap/_glyphicons.scss.

这里的问题就是node-sassie.如果指令太旧,libsass则不支持该@at-root指令.如果是这种情况,您将获得一个浏览器不知道该怎么做的@font-face包装@at-root.结果是没有下载任何字体,您可能会看到垃圾而不是图标.