css - 超大屏幕背景图片不显示

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

最佳答案

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

//注意 .在/assets 之前,如果您不使用 .它会给出 404 错误 -

关于css - 超大屏幕背景图片不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37831240/

相关文章:

html - 带有文本的 Bootstrap 行故障

Android:从静止图像制作动画

jquery - 使用jquery,我如何选择div内的所有图像来更改其源

javascript - CKEditor 和转义元素

jquery - 即使图像不存在,也会触发图像加载回调

css - 如何在 Avada WP 主题中添加自定义 css 响应?

javascript - 如何创建像 Google Chromebook 网站一样 Shiny 的 Logo

C# 电子邮件 - 新行未使用空白 : pre-wrap 呈现

html - 如何使用 CSS 在滚动的 <div> 中一层放置两个对齐的图像?

javascript - 如何将 bootstrap 4 导航保持在桌面标题下方,但在移动设备上方