jumbotron背景图像不显示

时间:2016-06-15 09:20:27

标签: css twitter-bootstrap image background

我想在后台显示图片但不显示:

<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>

我看到的是: enter image description here

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>

我收到这些错误: enter image description here enter image description here enter image description here

2 个答案:

答案 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>