我想在后台显示图片但不显示:
<div class="jumbotron jumbotron-fluid background: url('/assets/img/mhacks.jpg') no-repeat center center;">
<div class="container text-sm-center p-t-3">
<h1 class="display-2">Mona Jalal</h1>
<p class="lead">Under construction</p>
</div>
</div>
P.S。:一般情况下如何调试此类故障? 这是我的jsfiddle: https://jsfiddle.net/e5qsnjdo/
使用以下代码:
<div class="jumbotron jumbotron-fluid style="background-image: url('/assets/img/mhacks.jpg') no-repeat center center;">
<div class="container text-sm-center p-t-3">
<h1 class="display-2">Mona Jalal</h1>
<p class="lead">Under construction</p>
</div>
</div>
答案 0 :(得分:1)
将background
属性移至style
属性:
<div class="jumbotron jumbotron-fluid" style="background: url('/assets/img/mhacks.jpg') no-repeat center center;">
或者在css中定义如下:
.jumbotron {
background: url('./assets/img/mhacks.jpg') no-repeat center center;
}
//注意到。之前/资产如果你不使用。它会给出404错误 -
答案 1 :(得分:1)
<div class="jumbotron jumbotron-fluid" style=" background: url('/assets/img/mhacks.jpg') no-repeat center center;">
<div class="container text-sm-center p-t-3">
<h1 class="display-2">Mona Jalal</h1>
<p class="lead">Under construction</p>
</div>
</div>