【发布时间】:2014-11-22 12:47:56
【问题描述】:
我正在尝试从 Bootstrap2 升级到 Bootstrap3。到目前为止一切正常,除了 Glyphicons:显示一个正方形而不是图标:
我正在使用 Symfony2。这就是我调用 Bootstrap CSS 的方式:
<link rel="stylesheet" href="{{ asset('css/bootstrap.css') }}" type="text/css" />
这就是我对字形图标的称呼:
<span class="glyphicon glyphicon-search"></span>
我的文件结构如下:
- /网络
- /css
- bootstrap.css
- /字体
- 4 个字形图标文件
- /css
这似乎是一个常见问题(例如,请参阅 this topic、this topic 或 this topic),但在那里找到的解决方案都没有解决我的问题。
我从引导网站下载文件,而不是从定制器。 此外,我使用以下文件结构进行了测试(在一个完全不同的文件夹中,但具有相同的引导文件),在这些主题之一中找到:
- /测试
- /css
- bootstrap.css
- /字体
- 4 个字形图标文件
- index.html
- /css
Index.html 蜜蜂:
<!DOCTYPE html>
<html>
<head>
<meta chaset="utf-8">
<title>Test icons</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
<button type="button" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-star"></span> Star
</button>
</body>
</html>
而且这个测试完美运行,所以字形文件没有损坏。
我的真实网站的字符集也是 UTF-8。
我检查了 bootstrap.css 文件,glyphicons 参考似乎没问题:
@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');
}
.glyphicon {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
-webkit-font-smoothing: antialiased;
font-style: normal;
font-weight: normal;
line-height: 1;
-moz-osx-font-smoothing: grayscale;
}
所以我猜我称 CSS“修改”其路径的方式与 glyphicons 路径不同,即未找到图标。
我应该如何调用 CSS 或修改 src: url('????????/glyphicons-halflings-regular.eot');有正确的链接?
【问题讨论】:
标签: css symfony twitter-bootstrap-3