2016-09-19 48 views
0

我剛開始構建一個簡單的導航欄,並意識到頁面頂部有某種默認的填充/頁邊距。我嘗試使用margin:0 & padding:0,但它只修復了水平問題。我在OS X El Capitan上使用chrome。製作一個導航欄填充頂部空間(非body邊距:0;)

body{ 
 
\t margin:0; 
 
\t padding:0; 
 
} 
 

 
#navigation{ 
 
\t width:100%; 
 
\t height:auto; 
 
\t background-color:orange; 
 
} 
 

 
li{ 
 
    list-style-type:none; 
 
\t display:inline-block; 
 
}
<nav id="navigation"> 
 
    <ul> 
 
     <li><a href="#">Home</a></li> 
 
     <li><a href="">php stuff</a></li> 
 
     <li><a href="">about me</a></li> 
 
     <li><a href="">Contact</a></li> 
 
    </ul> 
 
</nav>

+2

右鍵單擊 - 檢查 - 檢查'ul'元素。 – Vucko

+0

我不期待那是愚蠢的。我不習慣使用檢查功能,我應該經常這樣做。謝謝哥們! – axul

回答

0

試試這個:

#navigation { 
width: 100%; 
height: auto; 
background-color: orange; 
position: absolute; 
top: 0px; 
} 
+1

這不是一個解決方案 – dippas

0

UL標記的默認填充/保證金建立了我的問題。