2015-11-23 39 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,則它們將具有相同的自定義背景,並且可能不是您想要的行爲。

相關問題