html - 如何解决没有在 Django 模板上加载的 CSS 背景图像
问题描述
嘿,所以我试图将背景图像注入到我的 Django 模板中,但是由于某种原因,我不知道为什么它没有加载我尝试在 html(**) 标记上进行内联样式设置,但什么也没有
我试图制作一个外部 css 文件,但仍然无法正常工作,你能告诉我我在这里可能做错了什么吗?
** 下面是我的 html 标签的代码,我想把背景图片放到**
<div class="hero-wrap js-fullheight" data-stellar-background-ratio="0.5">
<div class="overlay"></div>
<div class="container">
<div class="row no-gutters slider-text js-fullheight align-items-center justify-content-start" data-scrollax-parent="true">
<div class="col-md-6 ftco-animate">
<h2 class="subheading">Leave the house cleaning chores to us</h2>
<h1 class="mb-4">Let us do the dirty work, so you don't have to.</h1>
<p><a href="#" class="btn btn-primary mr-md-4 py-2 px-4">Learn more <span class="ion-ios-arrow-forward"></span></a></p>
</div>
</div>
</div>
</div>
下面是我为测试它是否可以使用外部样式表而制作的外部 css 文件
.hero-wrap js-fullheight{
background-image: url('static/images/bg_1.jpg');
}
如果可能的话,你能教我如何使用 Django 模板在 html 标签上制作内联背景图像
解决方案
试试这个:
<div class="hero-wrap js-fullheight" data-stellar-background-ratio="0.5" style="background-image: url({% static '/images/bg_1.jpg' %});">
推荐阅读
- css - 如何让图像在较小的屏幕上占据 100% 的宽度?
- spring - spring boot + hibernate 在我获得带有命名查询的项目后,我可以使用 entityMnager.persist(item) 吗?
- javascript - 无数次动态改变任何标签的id属性
- kubernetes - 无法连接到 AWS vm 上的 Kubernetes api
- elasticsearch - Kibana 中的日期差异脚本字段
- r - 在 R 中的大型数据集上获取所有可能的组合
- c# - 方法“登录”没有重载需要 4 个参数
- google-apps-script - GAS 代码通过 Telegram 将 google 表格作为 pdf 文件通过电子邮件发送给某人
- c# - 网格中的通用 JSON 反序列化
- python - 如何更快地从字符串列表构建自定义字典