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

1

0

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" %}");
}
Yeld answered 24/11, 2014 at 18:51 Comment(0)
S
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">
Shit answered 24/11, 2014 at 19:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.