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


当前回答

这个答案适用于任何使用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"));
}

其他回答

例如,如果您希望图标为glyphicon-chevron-left

尝试添加class="glyphicon glyphicon-chevron-left"

我也有类似的问题。 作为一个bootstrap的新手,原来我在图标名称之前缺少了glyphicon关键字。

<span class="glyphicon-search"></span>

应该是

<span class="glyphicon glyphicon-search"></span>

如果你使用Visual Studio(2015年,在我的情况下)来创建一个ASP。NET Webforms Web Application,带有Bootstrap主题,默认情况下,字形存储在项目根目录下的/fonts文件夹中。

如果您开始将/Content下的引导文件重新安排到子文件夹中(例如,支持多个主题),那么引导中的所有引用都将引导到../fonts/将中断。您可以将字体文件夹移动到/Content下适当的相对路径,或者重命名从../fonts到/fonts。

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

这就是为什么图标没有出现在我面前的原因:

* {
    arial, sans-serif !important;
}

在我已经删除了我的CSS的这一部分,一切都像它应该工作。重要的是引起麻烦的那个。