How do I put a background image on the body in css with django using static?

依然范特西╮ 提交于 2019-12-13 03:43:16

问题


How do I put a background image on the body in css with django using static?

Is it something like this? I can't find any information on this. Thanks.

{% load static %}
body {
    padding: 0 20px;
    background-image: url("{% static "assets/images/2.gif" %}");
}

回答1:


Use a relative path. Relative to the folder where the css file reside.

background: url('../assets/images/2.gif');

And use it in template file like this:

{% load staticfiles %}
<link href="{% static 'css_file_address' %}" rel="stylesheet" media="screen">


来源:https://stackoverflow.com/questions/27112050/how-do-i-put-a-background-image-on-the-body-in-css-with-django-using-static

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!