简体   繁体   中英

Bootstrap 3 - Jumbotron background image

I am having trouble setting a background image for bootstrap jumbotrons. My main.css comes after the bootstrap css and I am selecting the jumbotron using a class called "banner" which is in the same div as the jumbotron, but it still doesn't work. Here is my code...

HTML:

  <!-- Banner -->
  <div class="jumbotron banner">
    <div class="container">
      <hgroup>
        <h1>
          Bits king
        </h1>
        <h2>
          Web Design &amp; Development
        </h2>
      </hgroup>
    </div>
</div>

CSS:

 .banner {
  height: 400px;
  width: 100%;
  max-height: 50%;
  max-width: 100%;
  min-height: 20%;
  min-width: 30%;
  background-image: url("../assets/images/banner.jpeg");
  background-size: cover;
}

You can add a background-image property to the .jumbotron class in your custom css file (Make sure you reference your custom css file after Bootstrap. Here's an example:

.jumbotron {
    background-image: url("/img/your-image.jpg");
    background-color: #17234E;
    margin-bottom: 0;`enter code here`
    min-height: 50%;
    background-repeat: no-repeat;
    background-position: center;
    -webkit-background-size: cover;
    background-size: cover;
}

add "jumbotron-custom" to class attribute and apply this after "bootstrap" css :

.jumdotron-custom
{
    background: url('/*background url*/') no-repeat !important;
}

..or just add !important to your 'background-image' of css.

Good Morning. Try this:

background-image: url("../assets/images/banner.jpg");

Let me know if it works or not?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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