当我加载页面时,我的终端中收到以下消息:
Not Found: /fonts/glyphicons-halflings-regular.woff2
[24/Aug/2016 17:19:36] "GET /fonts/glyphicons-halflings-regular.woff2 HTTP/1.1" 404 2238
Not Found: /fonts/glyphicons-halflings-regular.woff
[24/Aug/2016 17:19:36] "GET /fonts/glyphicons-halflings-regular.woff HTTP/1.1" 404 2235
Not Found: /fonts/glyphicons-halflings-regular.ttf
我加载此字形图标的主页代码如下:
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'bootstrapmin.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" />
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<a class="navbar-brand" href="">
<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> 
<button class="btn-link" type="button"> OntoLogica</button>
</a>
</div>
</nav>
我的引导程序文件位于:
- My Project Folder
- static Folder
- 引导程序 min.css
- 样式.css
- fonts Folder
我尝试做的事情:
- 将字体文件夹的文件移动到引导程序的同一路径
- 将字体文件夹移到静态文件夹之外。
如果您需要我未提供的任何信息,请询问,我会的。
各位,怎么了?预先感谢您的任何帮助!
默认情况下,Bootstrap 的 CSS 定义了字体的相对路径,如下所示:
../fonts/glyphicons-halflings-regular.woff2
这意味着浏览器将尝试从 CSS 文件所在的目录向上查找fonts
目录。在您的项目结构的情况下,意味着它尝试获取/fonts/glyphicons-halflings-regular.woff2
代替/static/fonts/glyphicons-halflings-regular.woff2
这就是他们实际所在的地方。
最简单的解决方案是坚持文档中推荐的目录结构 http://getbootstrap.com/getting-started/#whats-included-precompiled并将所有 CSS 放入css
与站点处于同一级别的目录fonts
目录:
- static
- css
- bootstrap.min.css
- style.css
- fonts
- glyphicons-halflings-regular.woff2
显然,您现在必须使用以下命令来引用文件css
prefix:
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
更复杂的解决方案是下载一个定制 http://getbootstrap.com/customize/您可以在其中设置自定义的 Bootstrap 版本@icon-font-path
(注意默认值:"../fonts/"
)。根据您当前的项目结构,您需要将其更改为"/static/fonts/"
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)