2016-02-22 294 views
0

所以我一直在創建一個非常基本的網站,其中headernav,主容器和footer。我在我的網站上使用了viewport標籤。如何去除div標籤周圍的白色邊距?

我將divwidth設置爲100%時,出現了我的問題。

這裏是我的代碼:

#header { 
    background-color: black; 
    color: white; 
    text-align: center; 
    padding: 5px; 
} 
#nav { 
    line-height: 60px; 
    background-color: #FFFFFF; 
    min-height: 60px; 
    width: 100%; 
    left: 0px; 
    text-decoration: none; 
} 
#nav a { 
    font-family: sans-serif; 
    font-size: 25px; 
    text-decoration: none; 
    float: left; 
    margin-left: 10px; 
} 
#section { 
    min-width: 50%; 
    min-height: 479px; 
    float: left; 
} 
#section p { 
    font-family: sans-serif; 
    font-size: 20px; 
} 
#footer { 
    background-color: black; 
    color: white; 
    clear: both; 
    text-align: right; 
    line-height: 40px; 
    height: 40px; 
} 
#footer p { 
    margin-right: 30px; 
} 

有什麼我需要改變,以擺脫周圍的DIV的白邊的,我已經試過的事情,才能擺脫它,但他們都不工作, 任何幫助將不勝感激。

+1

您可以將您的HTML代碼,請?通過「白色邊緣」來理解你的意思會更容易。 –

回答

2

body跨瀏覽器有默認margin,所以您需要重置margin

所以加這

body { 
    margin: 0 
} 
0

你談論的網站周圍的白邊,然後使用

html, body { 
    margin: 0; 
    padding: 0; 
    overflow-x: hidden; 
}