0

How to get the path to work so it shows the background image through css? If it could be done with a relative path then how?

right now with this code, the background image is not being displayed.

Thanks for any help.

/*mobile view*/
.index-banner {
    background: url('static/mysite/images/home.svg') no-repeat;
    background-position: center;
    background-size: cover;
    width: 100%;
    height: 380px;

}
{% block content %}
    <section class="index-banner">
        <h2>Test<br>Condiitons</h2>
        <h1>lorel ipsum</h1>
        <h1>sdfjls upueh ndsfoi bbownl</h1>
        <img src="{% static 'mysite/images/home.svg' %}" class="mysite-img" style="display: none;">
    </section>
{% endblock %}

2
  • What exactly is happening? What is the error you are getting? Commented Apr 5, 2020 at 21:59
  • not exactly an error, it's not displaying the image Commented Apr 5, 2020 at 23:31

1 Answer 1

1

figured out the way, so if you have your settings.py set to STATIC_URL = '/static/' then background: url('/static/movies/images/home.svg') no-repeat; should work, what I was missing was a pre'/' before the static

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.