简体   繁体   English

Jumbotron BG图像可调整大小,不会显示

[英]Jumbotron BG image resizeable, wont show up

might be a stupid question but i am trying to fix my Jumbotron header with a bgimage..it did work before but the image was squished when resized..found a workaround but now it kinda doesnt show up anymore : 可能是一个愚蠢的问题,但是我尝试使用bgimage修复我的Jumbotron标头。它确实可以工作,但是调整大小后图像被压缩了。找​​到了一种解决方法,但是现在它不再显示了:

<div class="container">
    <div class="row">
        <div class="col-md-12 jumbotron" id="jumbotronBG">
            <div class="text-center">
                  <h1>BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA</h1>
                  <a href="#services" class="btn btn-md btn-danger">SERVICES</a>
                  <a href="#companies" class="btn btn-md btn-success">COMPANIES</a>
            </div>
        </div>
    </div>

 .jumbotronBG {
  background: url('../img/bg.jpg') no-repeat center center !important;
  position: fixed !important;
  width: 100% !important;
  height: 350px !important; /*same height as jumbotron */
  top:0 !important;
  left:0 !important;
  z-index: -1 !important;
}

.jumbotron {
  margin-bottom: 40px !important;
  height: 350px !important;
  color: white !important;
  text-shadow: black 0.1em 0.3em 0.3em !important;
  background:transparent !important;

}

You have a .jumbotronBG class in your CSS, but you are not using it in your HTML. 您的CSS中有一个.jumbotronBG类,但是您没有在HTML中使用它。

Just change your ".jumbotronBG" class definition in your CSS file to this: "#jumbotronBG" and the styles will be applied correctly. 只需将CSS文件中的“ .jumbotronBG”类定义更改为:“ #jumbotronBG”,即可正确应用样式。

You could also put the background style inside the ".jumbotron" class definition, but if you use more than one jumbotron in your project, all them will have the same customized background and that may not be your desired behavior. 您也可以将背景样式放在“ .jumbotron”类定义中,但是如果您在项目中使用多个jumbotron,则它们将具有相同的自定义背景,这可能不是您想要的行为。

just add your background url to .jumbotron class. 只需将您的背景网址添加到.jumbotron类。

html html

<div class="container">
<div class="row">
    <div class="col-md-12 jumbotron">
        <div class="text-center">
              <h1>BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA</h1>
              <a href="#services" class="btn btn-md btn-danger">SERVICES</a>
              <a href="#companies" class="btn btn-md btn-success">COMPANIES</a>
        </div>
    </div>
</div>

and css 和CSS

.jumbotron {
  background-image: url('../img/bg.jpg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  margin-bottom: 40px !important;
  color: white !important;
  text-shadow: black 0.1em 0.3em 0.3em !important;
}

https://jsfiddle.net/eaxzjmmk/ https://jsfiddle.net/eaxzjmmk/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM