一個像素我有兩個div
-elements,最上面的一個具有40%高度,而另一個60%。 在我的例子中,我將第一個定位到top: 0;
,第二個定位到bottom: 0;
。我的問題是,我有時在Webkit中獲得它們之間1px的距離,有時候!通過百分比(%)在Webkit的
我創建了一個的jsfiddle,再現WebKit中的問題(Safari和Chrome,但在Firefox正常工作。)
http://jsfiddle.net/bVxDA/(調整窗口的大小在行動中看到的bug)
這是我正在使用的代碼。
HTML
<div id="cover-top"></div>
<div id="cover-bottom"></div>
CSS
html, body {
background: red;
height: 100%;
}
#cover-top,
#cover-bottom {
background: #000;
position: absolute;
width: 100%;
}
#cover-top {
height: 40%;
top: 0;
}
#cover-bottom {
height: 60%;
bottom: 0;
}
我會被罰款與使用JavaScript或jQuery的解決方案。
證明:http://jsfiddle.net/iambriansreed/gPu3Y/ – iambriansreed 2012-03-20 16:08:43