如果Bootstrap CSS文件在本地托管,则Glyphicons会损坏

时间:2014-02-03 18:01:25

标签: css twitter-bootstrap character-encoding twitter-bootstrap-3 webfonts

我正在项目中使用Twitter Bootstrap 3.0。有一个固定的要求是不在外部托管任何文件。但是,当我在本地托管.css.js个文件时,Glyphicons会损坏。

这是它应该是什么样子:

enter image description here

使用bootstrap.min.css from the original CDN不会发出任何错误,但在本地服务器上放置相同的文件会影响图标呈现,如下图所示:

enter image description here

如果我使用wget,DownThemAll下载并保存原始文件似乎并不重要,或者在Firefox上打开并使用“另存为”功能。 <link> href是href="/css/bootstrap.min.csshref="http://www.domain.com/css/bootstrap.min.css还是href="http://www.domain.com/bootstrap.min.css并不重要。

我的开发机器正在运行Linux。我只能在我的开发机器和生产中使用它来浏览网站。我使用的是Firefox 26,but changing the value of security.fileuri.strict_origin_policy没有效果。据我所知,造成渲染错误的唯一区别是CSS文件位置。

问题发生在我的开发机器和实时服务器上。

1 个答案:

答案 0 :(得分:3)

Glyphicons是从Twitter Bootstrap的CDN版本中硬编码的地址加载的webfonts。原始代码是:

  

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

您必须编辑CSS或将字体文件放在/fonts/文件夹中。您可以在“customize”页面获取字体和CSS文件。