我从NuGet获得了Bootstrap。当我发布我的网站时,字形不起作用。
在我的情况下,我通过将每个字体文件的Build Action设置为'Content'并将它们设置为'Copy Always'来实现它。
这是您在bootstrap 3中包含图标的方式
<span class="glyphicon glyphicon-bell"></span>
http://glyphicons.bootstrapcheatsheets.com/
希望有所帮助。
例如,确保您没有指定字体系列
*{font-family: Verdana;}
将从i元素中删除halflings字体。
@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');}
我使用bootstrap与命名空间和glyphicons不工作,但在代码glyphicons上面添加上面的行工作正常。
我有这个问题,它是由variables.less文件引起的。覆盖它以设置icon-font-path值解决了问题。
结构化文件如下所示:
\Content \Bootstrap \Fonts styles.less variables.less
在Content的根目录中添加我自己的variables.less文件并在styles.less中引用它解决了404错误。
Variables.less包含:
@icon-font-path: "fonts/";
我正在仔细阅读我的这个老问题,因为到目前为止我应该给出正确的答案,我在评论中给出了这一点,我认为我也值得赞扬。
问题在于这个问题 的 从bootstrap的自定义工具下载的glyphicon字体文件与从bootstrap主页上找到的重定向下载的字体文件不同。 强> 那些正常工作的是可以从以下链接下载的那些:
http://getbootstrap.com/getting-started/#download
任何有旧的自定义程序文件问题的人都应该覆盖上面链接中的字体。
对我有用的是取代以下路线:
@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'); }
至
@font-face { font-family: 'Glyphicons Halflings'; src: url('/assets/glyphicons-halflings-regular.eot'); src: url('/assets/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('/assets/fonts/glyphicons-halflings-regular.woff') format('woff'), url('/assets/glyphicons-halflings-regular.ttf') format('truetype'), url('/assets/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); }
正如@Stijn所描述的那样,默认位置在 Bootstrap.css 安装此程序包时不正确 Nuget 。
Bootstrap.css
Nuget
将此部分更改为如下所示:
@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'); }
您必须按此顺序设置:
<link rel="stylesheet" href="path/bootstrap.min.css"> <style type="text/css"> @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'); } </style>
我修改了less less.less文件 我修改了变量
原来是
@icon-font-path: "../fonts/";
这引起了一个问题
以下是为我修复它的原因。我在Firebug控制台中使用“错误的URI”错误。图标显示为E ###数字。我必须在我的'fonts'目录中添加一个.htaccess文件。 <FilesMatch "\.(ttf|otf|eot|woff)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch> 可能重复: firefox上的可下载字体:不允许使用错误的URI或跨站点访问
<FilesMatch "\.(ttf|otf|eot|woff)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch>
另一个问题/解决方案可能是使用此Bootstrap 2.x代码:
<button class="btn" ng-click="open()"><i class="icon-calendar"></i></button>
当基于的迁移时 指南 ( .icon-* ---> .glyphicon .glyphicon-* ):
.icon-* ---> .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>
您可以添加这行代码并完成。
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
谢谢。
我刚刚使用Ctrl + c,Ctrl + v重命名了bootstrap.css中的字体,并且它工作正常。
注意:下面可能是一个利基场景,但我想分享它以防其他人可能发现它有用。
在rails项目中,我们正在重复使用一个使用Rails引擎的gem bootstrap-sass 。除了glyphicon字体路径分辨率之外,所有在主项目中都很好。
bootstrap-sass
GET http://0.0.0.0:3000/fonts/bootstrap/glyphicons-halflings-regular.woff 404 (Not Found)
我们发现了 $bootstrap-sass-asset-helper 是 false 在决议期间我们预计它是真的,所以路径是不同的。
$bootstrap-sass-asset-helper
false
我们造成了 $bootstrap-sass-asset-helper 通过执行以下操作在引擎gem中初始化:
// explicit sprockets import to get glyphicon font paths correct @import 'bootstrap-sprockets'; @import "bootstrap/variables";
例如这导致路径解析为:
/assets/bootstrap/glyphicons-halflings-regular.woff
同样,在使用的任何普通轨道项目中都不需要这样做 bootstrap-sass ,我们恰巧正在重复使用很多观点,这对我们来说很有用。希望这可以帮助别人。
以下是关于不渲染字体的官方文档。
更改图标字体位置 Bootstrap假设图标字体文件将位于../fonts/目录中,相对于已编译的CSS文件。移动或重命名这些字体文件意味着以三种方式之一更新CSS: 更改源Less文件中的@ icon-font-path和/或@ icon-font-name变量。 利用Less编译器提供的相对URL选项。 更改已编译CSS中的url()路径。 使用最适合您特定开发设置的选项。
除此之外,你可能错过了复制 的 fonts文件夹到根目录 强>
我有一个盒子宽度代码\ e094用于glyphicon-arrow-down,实际上我解决了添加的问题 的 glyphicon 强> 在css类中:
<i class="glyphicon glyphicon-arrow-down"></i>
如果它可以帮助某人......
您的fonts目录中是否包含以下所有文件?
glyphicons-halflings-regular.eot glyphicons-halflings-regular.svg glyphicons-halflings-regular.ttf glyphicons-halflings-regular.woff
IIS不会服务器 .woff 默认情况下是文件,所以在IIS中你需要添加一个 <mimeMap> 进入你的 web.config 文件;
.woff
<mimeMap>
web.config
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <staticContent> <mimeMap fileExtension=".woff" mimeType="application/x-woff" /> </staticContent> </system.webServer> </configuration>
这是由于bootstrap.css和bootstrap.min.css中的编码错误造成的。从Customizer下载Bootstrap 3.0时,缺少以下代码:
由于这是使用Glyphicons的主要代码,因此它不会起作用...
从完整包中下载css文件,将实现此代码。