【发布时间】:2020-12-15 09:49:40
【问题描述】:
我刚刚在这里覆盖了引导程序,并确保它是从我的本地 css 中提取的,对它的任何其他更改都可以工作,但是当我尝试插入背景图像时,只有 localhost url 用于图像工作,如果我指定本地路径它没有。我尝试了所有变体,也是静态的背景图像: url("{% static 'portfolio/waterfall.jpg' %}"); 我正在使用 Django,之前我的 settings.py 出现了问题-这会导致它吗?谢谢 #settings.py
STATIC_URL = '/static/'
MEDIA_ROOT = BASE_DIR / 'media'
MEDIA_URL = '/media/'
#this is the jumbotron Im试图获取背景
<section class="jumbotron text-center">
<div class="container">
<h1>Album example</h1>
<p class="lead text-muted">Something short and leading about the collection below—its contents, the
creator, etc. Make it short and sweet, but not too short so folks don’t simply skip over it entirely.
</p>
<p>
<a href="#" class="btn btn-primary my-2">Main call to action</a>
<a href="#" class="btn btn-secondary my-2">Secondary action</a>
</p>
</div>
</section>
#和自定义的.css
.jumbotron {
padding: 2rem 1rem;
margin-bottom: 2rem;
background-color: #c5b8b8;
border-radius: .3rem;
background-image:
url("media/portfolio/images/foster-s-home-for-imaginary-friends-fosters-home-for-imaginary-friends-_ER46ne1.jpg");
background-repeat: no-repeat;
background-position: bottom center;
background-size: cover;
}
【问题讨论】:
标签: html css django bootstrap-4