简体   繁体   中英

Django CMS - How to add background image in cms

I have been using placeholder to change images and text in html template like this:

{% block newsimage %}
{% placeholder "newsimage" %}
{% endblock newsimage %}

But in one particular html file, the background image have been called from class using css - for example:

HTML:

<div class="container">
...
</div>

CSS:

.container {
    background: url(../images/sample.jpg);
    background-size: cover;
    background-repeat: no-repeat;
    height: 468px;
}

So I'm not able to add placeholder for this image.

How can I add background image for this template in django cms?

You could add inline CSS to the template, after the external CSS is loaded, eg

<style>.container {background: url({% placeholder "newsimage" %});}</style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM