无法正确显示Twitter Bootstrap glyphicons

时间:2013-08-07 17:20:31

标签: twitter-bootstrap angularjs glyphicons

我正在使用Angular.js Todo应用视频教程,我遇到了一个问题,包括index.html文件中的Twitter Bootstrap 3 glyphicons(图标显示为非描述性图片,无论是在Chrome还是在火狐)。

这就是我在index.html中添加bootstrap和bootstrap-glyphicons css文件的方法:

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
  <script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
  <script type="text/javascript" src="todo.js"></script>
  <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-glyphicons.css">
  <link rel="stylesheet" href="todo.css">
</head>

这就是我稍后在文件中添加所需的glyphicon的方法:

<form class="form-horizontal">
  <input type="text" ng-model="formTodoText" ng-model-instant>
  <button class="btn"><i class="glyphicon glyphicon-plus"></i>Add</button>
</form>

bootstrap-glyphicons字体文件位于bootstrap / css / fonts中。具体来说,文件是:

  1. glyphiconshalflings-regular.eot
  2. glyphiconshalflings-regular.otf
  3. glyphiconshalflings-regular.svg
  4. glyphiconshalflings-regular.ttf
  5. glyphiconshalflings-regular.woff
  6. 有关如何正确访问图标的任何想法?非常感谢你的帮助!

1 个答案:

答案 0 :(得分:6)

我首先检查你的libs上的版本。

如果您使用this pull request之前的版本,则可能指向不存在的资产。 Bootstrap 3.0.0-wip分支将glyphicons抽象为 this repo

我还会在URL资产路径之前加上/来从基本网址调用。

<link rel="stylesheet" href="/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="/bootstrap/css/bootstrap-glyphicons.css">

在正式的glyphicons着陆器上,一个示例使用<span></span>而不是<i></i>

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

他们有可能改变这种惯例。

修改

在源代码中,您将看到资产的绝对路径。仔细检查您的fonts目录是否与css目录处于同一级别。

src:url('../fonts/glyphiconshalflings-regular.eot');