2015-09-23 15 views
0

我已經在角視圖下的div,這是所有在視圖中截至目前Div的高度由文字高度內確定,我不想要這個

<div class="home-container" ng-controller="ctrlHome" > 
HELLO 
</div> 

我想設置它的背景圖像佔用頁面的其餘部分或相同數量的身體

這裏是CSS

html { 
    height: 100%; 
} 

body { 
    font-family: "Hero", Times, serif !important; 
    min-height: 100%; 
} 

.home-container { 
    background: url('../images/94H.jpg') no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    min-height: 100%; 
    clear:both; 
} 

所有我得到它的圖像文本HELLO這是20像素的高度這可能是東西容易,我搞砸了,但是這是令人沮喪的非少 在此先感謝

image of div being height of text

+1

嘗試加入'html'身體規則...'HTML,身體{...' – charlietfl

回答

0

使用height: 100%而不是最小高度。同時添加html的CSS規則,因爲身體需要父元素來計算height: 100%

html, 
 
body { 
 
    font-family: "Hero", Times, serif !important; 
 
    height: 100%; /* Changed */ 
 
} 
 
.home-container { 
 
    background: url('http://placehold.it/600x1200') no-repeat center center fixed; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
    min-height: 100%; 
 
    clear: both; 
 
}
<div class="home-container" ng-controller="ctrlHome"> 
 
    HELLO 
 
</div>

+0

做沒有區別 – JKX

+0

它在代碼段中工作嗎? –

+0

是的,但它是一個視圖,它可能會影響它,我會告訴你我想要,我會添加一個圖像 – JKX