2017-05-05 128 views
0

由於某些原因,我無法使網頁的寬度完全爲100%,它似乎總是有一個滾動條。我甚至回到基礎知識,不能解決它,所以希望它只是我愚蠢!HTML 100%寬度比頁面寬

有人可以來看看,請

* { 
 
    -webkit-box-sizing: border-box; 
 
    -moz-box-sizing: border-box; 
 
    box-sizing: border-box; 
 
} 
 

 
body { 
 
    background-color: #393939; 
 
    font-family: Arial, sans-serif; 
 
    height: 100%; 
 
    width: 100%; 
 
    color: #f2f2f2; 
 
}
Hello World

+0

'是,在現有的網站呢? – scarsam

+1

'body'具有默認邊距。刪除這些,你會沒事的。另外,對於像'body'這樣的塊級元素,不需要'width:100%;',這有點多餘。 – hungerstar

+0

@scarsam不,這只是一個錯字 –

回答

2

清除在body邊緣使用margin: 0;

* { 
 
    box-sizing: border-box; 
 
} 
 

 
html { 
 
    height: 100%; 
 
} 
 

 
body { 
 
    background-color: #393939; 
 
    font-family: Arial, sans-serif; 
 
    height: 100%; 
 
    width: 100%; 
 
    color: #f2f2f2; 
 
    margin: 0; 
 
}