python - 通过css为django模板加载图片

标签 python django

我的 django 站点主题中有这样的文件夹结构:

enter image description here

<小时/>

索引文件加载style.css,style.css应该加载我的bg.jpg,我在style.css中执行此操作:

body  {
    background:#fff url('../images/images/bg.jpg') repeat-x;
}

但是没用,我也试过了:

body  {
        background:#fff url('sitestatic/images/images/bg.jpg') repeat-x;
    }

CSS URL:/sitestatic/css/style.css

图片网址:/sitestatic/images/images/bg.jpg

如何通过 style.css 加载这张图片?

最佳答案

您可能想阅读有关 how to manage static files with django 的文档.

关于python - 通过css为django模板加载图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7645119/

相关文章:

python - uWSGI服务器没有响应

python - 带有列表的 if 语句包含

python - 在python中向XML添加子元素

python - python中的import关键字实际上是如何工作的?

python - Django Filter 推导出ManyToMany

django - (Django) 事件日历的最佳解决方案

python - 在基维上课时播放/停止音乐

python - networkx 绘制函数的图例

javascript - 如何在django中添加JS

python - Django 类 View 和反向 URL