2015-11-23 35 views
0

可能是一个愚蠢的问题,但我试图修复我的Jumbotron标题与bgimage ..它做过的工作之前,但图像被压扁时调整..找到一个解决方法,但现在它挺犯规了显示:Jumbotron BG图像可调整大小,不会显示

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

} 
+0

非常感谢您的帮助:-) – HendrikEng

+0

在您的CSS中将'.jumbotronBG'改为'#jumbotronBG',看看会发生什么。 – wmeade

+0

刚刚意识到误入歧途,并尝试它,但不幸它让一切可怕,仍然没有BG形象..我想我有它之前没有线索我摧毁..感谢:-) – HendrikEng

回答

0

只需添加你的背景网址.jumbotron类。

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> 

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

+1

非常感谢...有一个奇怪的云9错误..每当我改变它,并刷新预览它只是出现一秒钟,然后走了然后..它完美的作品现在..感谢很多人 – HendrikEng

+0

不客气:) – eatik

1

你在你的CSS .jumbotronBG类,但是你是不是在你的HTML中使用它。

只需将CSS文件中的“.jumbotronBG”类定义更改为:“#jumbotronBG”,并且样式将被正确应用。

您也可以将背景样式放在“.jumbotron”类定义中,但是如果您在项目中使用多个jumbotron,则它们将具有相同的自定义背景,并且可能不是您想要的行为。

相关问题