我有过
<div class="p-5 back-image corner-radius" >{{obj.app_name}}</div>
为此,我需要像这样添加css
.back-image {
background: url("/static/boss/slider-2.jpg") 50% fixed;
}
这在本地主机上工作得很好,但现在我使用s3存储桶来为静态文件提供服务器
background: url("/static/boss/slider-2.jpg") 50% fixed; // not working still picking localhost
background: url("'{{static}}'/boss/slider-2.jpg") 50% fixed; // not working
background: url("'{{STATIC_URL}}'/boss/slider-2.jpg") 50% fixed; // not working
如何解决这个问题,这是可能的吗?
发布于 2019-03-01 06:02:17
在您的案例中使用内联css
<div class="p-5 corner-radius" style="background: url('{% static 'boss/slider-2.jpg' %}') 50% fixed;">{{obj.app_name}}</div>
https://stackoverflow.com/questions/54938554
复制