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


当前回答

如果其他解决方案不起作用,您可能希望尝试从外部源导入Glyphicons,而不是依赖Bootstrap为您完成所有工作。这样做:

你可以在HTML中这样做:

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">

或CSS:

@import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css")

来自这个线程的信用edsiofi: Bootstrap 3 Glyphicons CDN

其他回答

这个答案适用于任何使用Nancy (Nancy fx)的人。

我有一个ASP。net托管的NancyFX应用程序,我通过NuGet获得了Boostrap。

我的字形不能工作,但事实证明不是糟糕的字体文件、不正确的CSS相对目录路径或其他答案中提到的任何其他事情的问题。

问题是我错过了一个惯例,告诉南希去哪里寻找内容。一旦我意识到这一点,解决方案就是简单地在我的bootstrapper文件中添加以下重载:

protected override void ConfigureConventions(NancyConventions nancyConventions)
{
    base.ConfigureConventions(nancyConventions);
    nancyConventions.StaticContentsConventions.Add(
        StaticContentConventionBuilder.AddDirectory("/fonts"));
    nancyConventions.StaticContentsConventions.Add(
        StaticContentConventionBuilder.AddDirectory("/Scripts"));
}

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

文件结构如下所示:

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

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

变量。不包含:

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

这是由于bootstrap.css和bootstrap.min.css中的错误编码。当你从定制器下载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');
}

因为这是使用Glyphicons的主要代码,所以它不会在ofc…

从完整的包中下载css文件,这段代码将被实现。

注意:下面可能是一个小众场景,但我想分享它,以防其他人可能会发现它有用。

在一个rails项目中,我们通过使用bootstrap-sass的rails引擎gem重用了很多东西。除了象形字体路径分辨率外,主项目中一切都很好。

GET http://0.0.0.0:3000/fonts/bootstrap/glyphicons-halflings-regular.woff 404 (Not Found) 

我们发现$bootstrap-sass-asset-helper在解析期间为假,而我们期望它为真,因此路径不同。

我们在引擎gem中初始化了$bootstrap-sass-asset-helper:

// explicit sprockets import to get glyphicon font paths correct
@import 'bootstrap-sprockets';
@import "bootstrap/variables";

例如,这导致路径解析为:

/assets/bootstrap/glyphicons-halflings-regular.woff

同样,这在任何使用bootstrap-sass的正常rails项目中都不应该是必要的,我们只是碰巧重用了很多视图,这对我们来说很有效。希望这能帮助到其他人。

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

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