【发布时间】:2017-05-18 15:19:57
【问题描述】:
我刚刚将我的 Django 1.10 (Python 3.5) 应用升级到 Django 1.11 (Python 3.6)。大多数事情仍然有效,但由于某种原因,我的 CSS 背景图像不再被渲染(我尝试使用旧版本,它仍然可以在那里工作)。这只发生在 CSS 上,当它是 HTML 标记时仍然正常加载。
这是我第一次处理我的 Django 应用程序的更新,所以我不太确定处理这些小问题的正确方法是什么。
我一直在为背景图片尝试不同的方法,但都没有奏效。
这是我失败的代码,
{% extends 'base.html' %}
{% load staticfiles %}
{% block style %}
<style>
#top {
/*background: url("{% static 'img/skyscraper.jpg' %}") no-repeat center center fixed;*/
background: url("/static/img/skyscraper.jpg");
/*background: url('{{ STATIC_URL }}img/skyscraper.jpg');*/
background-attachment: scroll;
background-size: cover;
min-height: 700px;
}
</style>
{% endblock %}
【问题讨论】: