【发布时间】:2013-10-12 17:41:58
【问题描述】:
好的,所以我的 base.html 模板在
/home/user/documents/project/app/templates/base.html
我的 style.css 在
/home/user/documents/project/app/static/css/style.css
我的 consola.ttf 字体在
/home/user/documents/project/app/static/fonts/consola.ttf
我的 static_URL 是
STATIC_URL = '/static/'
我的 STATIC_ROOT 是
STATIC_ROOT = '/home/user/documents/project/app/static'
现在,如何将 style.css 链接到我的 base.html 模板? 我试过做
但它没有用。另外,如何在 style.css 中加载 consola.ttf 字体? 由于 style.css 和 consola.ttf 字体都在同一个静态文件夹中,我尝试这样做
@font-face { font-family: consola; src: url(../../fonts/consola.ttf'); }
但这也没有用。关于如何解决这两个问题的任何想法?
这是我的 .html 模板的开头。
<html>
<head>
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/style.css" />
<title>{% block title %}Name{% endblock %}</title>
</head>
应该是这样的,对吧?
【问题讨论】:
-
您尝试将 style.css 链接到 base.html 模板做什么?
-
我试过 但没用
-
你的
TEMPLATE_CONTEXT_PROCESSOR中有django.core.context_processors.static吗? -
啊,好吧我没有,所以我猜这就是问题所在。
-
好吧,没关系,问题仍然存在,由于某种原因,CSS 仍然没有链接。我把我的 .html 模板放在了开头。它看起来是正确的,对吧?
标签: css django import django-templates font-face