【问题标题】:Django template CSS/IMG is "off" in the URLDjango 模板 CSS/IMG 在 URL 中“关闭”
【发布时间】:2012-06-05 08:25:24
【问题描述】:

我有

/path/to/my/theme/static/css/frontend.css

由base.html调用

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/frontend.css" media="all" />

我有一个标题的背景:

#header-wrapper 
        min-width: 960px;
        height: 150px;
        background: transparent url(img/header-bg.png) repeat-x center bottom;
}

文件是

/path/to/my/theme/static/img

我已经运行 manage.py collectstatic 来收集文件,除了生成的链接看起来像:http://example.com/static/css/img/header-bg.png

其中没有显示图片,因为正确的网址是:http://example.com/static/img/header-bg.png

我哪里错了??

【问题讨论】:

  • url() 是相对于 css 文件的路径:也许你可以使用url(../img/header-bg.png)。身份证。
  • @jpaugh:为什么不将该评论更改为正确答案?我会说这是正确的答案。 :)

标签: django django-templates


【解决方案1】:

url() 相对于 css 文件的路径:也许你可以使用 url(../img/header-bg.png)

【讨论】:

    猜你喜欢
    • 2019-02-03
    • 1970-01-01
    • 2015-12-19
    • 2011-01-13
    • 1970-01-01
    • 2012-09-10
    • 2012-09-19
    • 2016-05-05
    • 1970-01-01
    相关资源
    最近更新 更多