2013-12-11 75 views
0

我有一個div,我基本上想要在整個視口上拉伸。Div高度正在搞亂

當縮小其完美的,因爲你可以看到黑色背景覆蓋所有的視口:

height is perfect, it fills the screen!

當我在約150-175%的高度弄亂了放大,使背景在它後面可見。這是不是我想要的,看到圖像的底部:

see bottom of image, height messes up, does not fill document height

有沒有簡單的解決方案呢?

在此先感謝!

這裏是我的HTML:

<div id="x_all"> 

</div> 

和CSS:

#x_all{ 
    position: absolute; 
    top:0px; 
    bottom:0px; 
    width: 100%; 
    height: 100% !important; 
    background-color: rgba(1, 1, 1, .9); 
    z-index: 399; 
} 
+0

您正在使用哪種瀏覽器?每種瀏覽器縮放行爲都不同。也許嘗試設置身體寬度和身高爲100%,但這只是一個瘋狂的猜測。 – matteok

+0

我正在使用Chrome – cwiggo

回答

2

這是因爲你使用的位置是:絕對

而是添加

位置:固定;

並且不要忘記添加

left:0px;

否則,您會在頁面左側留下白色的空白。

+0

謝謝Ned!腦子瘋了,知道這很簡單! – cwiggo

+0

祝你的項目好運:) – Ned