我下载了引导3.0,但无法让象形文字工作。我得到一些"E003"错误。知道为什么会这样吗?我在本地和网上都试过了,还是遇到同样的问题。


当前回答

我遇到了这个问题,它是由变量引起的。更少的文件。重写它以设置icon-font-path值解决了这个问题。

文件结构如下所示:

\Content
        \Bootstrap
        \Fonts
 styles.less
 variables.less

添加我自己的变量。在Content的根目录中添加less文件,并在样式中引用它。Less解决了404错误。

变量。不包含:

@icon-font-path:          "fonts/";

其他回答

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

<button class="btn" ng-click="open()"><i class="icon-calendar"></i></button>

当基于指南进行迁移时(。图标-*——> .glyphicon .glyphicon-*):

<button class="btn btn-default" ng-click="open()"><i class="glyphicon-calendar"></i></button>

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

<button class="btn btn-default" ng-click="open()"><i class="glyphicon glyphicon-calendar"></i></button>

正如@Stijn所描述的,当从Nuget安装这个包时,Bootstrap.css中的默认位置是不正确的。

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

@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');
}

如果有人在这里结束并使用引导>= v4.0:取消对字形的支持

发行说明中的相关部分:

删除Glyphicons图标字体。如果你需要图标,一些选项是: Glyphicons的上游版本 Octicons 字体太棒了

来源:https://v4-alpha.getbootstrap.com/migration/组件

如果你想使用象形文字,你需要单独下载。

我个人尝试过Font Awesome,它是相当好的。添加图标的方式类似于glypicon:

<i class="fas fa-chess"></i>

您的字体目录中是否有以下所有文件

glyphicons-halflings-regular.eot
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff

这是一个很长的拍摄,但这是我的案子,既然它已经不在这里了。

如果你从SASS编译Twitter Bootstrap使用gulp-sass或咕哝- SASS ie。node-sass。确保您的节点模块是最新的,特别是如果您正在处理一个相当旧的项目。

事实证明,在一段时间以前,SASS指令@at-root被用于字形中的@font-face的定义中,请参阅https://github.com/twbs/bootstrap-sass/blob/b01ab4942233bd7316a0634472e1243b13fb9f46/assets/stylesheets/bootstrap/_glyphicons.scss。

这里的问题在于。如果@at-root指令太旧,Libsass不支持它。如果是这种情况,您将得到一个@font-face包裹在@at-root中,浏览器不知道该如何处理。这样做的结果是不会下载任何字体,你可能会看到垃圾而不是图标。