【发布时间】:2015-06-14 01:22:02
【问题描述】:
我正在尝试从 css 文件中访问我的静态图像目录 (/static/myapp/images/)。
我最初尝试过这个:
{% load staticfiles %}
#header {
position:relative;
width: 680px;
height:99px;
margin-left:29px;
margin-right:21px;
background: url({% static 'myapp/images/header.png' %}) no-repeat;
}
但这不起作用
但是这很好用:
#header {
position:relative;
width: 680px;
height:99px;
margin-left:29px;
margin-right:21px;
background: url(../images/header.png) no-repeat;
}
Django 模板语言可以在 css 文件中使用吗?
还是只是我的语法,缺乏对 css 的理解!这个css来自我下载的一个简单模板,我对css一无所知,有没有另一种方法可以在这里链接一个模板语言可以使用的图像?
谢谢!
【问题讨论】:
标签: python html css django django-templates