我需要創建元素,覆蓋整個頁面,除了20px的邊緣。我嘗試this,它在WebKit瀏覽器和Firefox的作品,不過IE(10)和Opera有問題,這種:-(。不知道如何解決這個問題?元素必須覆蓋整個頁面,除了20px的餘量
HTML
<div id="first">
<div id="second">
Hello world!
</div>
</div>
CSS
head, body
{
width: 100%;
height: 100%;
}
body
{
position: absolute;
margin: 0;
background-color: blue;
display: table;
}
#first
{
display: table-cell;
height: 100%;
width: 100%;
padding: 20px;
}
#second
{
height: 100%;
width: 100%;
background-color: white;
}
display:table屬性沒有被IE正確支持,因此不鼓勵使用。注意:「inline-table」,「table」,「table-caption」,「table-cell」,「table-column」,「table-column-group」,「table-row」,「table-row -group「和」inherit「在IE7及更早版本中不受支持。 IE8需要!DOCTYPE。 IE9支持這些值。 –