2017-05-08 118 views
1

我試圖創建一個帶有標誌的導航欄。我有導航欄基本上工作,但頁面內容的標題也被迫進入導航欄。 enter image description here導航欄干擾標題HTML/CSS

這是我的HTML和我的網站的鏈接完整的源和觀看(http://frankkreutzer.com/

 <header class="section"> 
     <a id="logo" href="http://frankkreutzer.com"><img src="images/logo.png" width="75" height="75"></a> 
     <nav> 
      <ul> 
       <li><a href="http://frankkreutzer.com" id="current">Home</a></li> 
       <li><a href="http://frankkreutzer.com/it-130/assignment-3/assignment3.html" target="_blank">IT 130</a></li> 
       <li><a href="http://frankkreutzer.com/csgo/csgo-home.html" target="_blank">CS:GO Project</a></li> 
       <li><a href="http://frankkreutzer.com/cth-247/index.html" target="_blank">CTH Final Project</a></li> 
       <li><a href="http://frankkreutzer.com/contact.html">Contact Me</a></li> 
      </ul> 
     </nav> 
    </header> 

下面是一些我的CSS:

header { 
top: 0; 
right: 0; 
left: 0; 
border-bottom: 1px solid #e3e3e8; 
} 

#logo { 
    float: left; 
    font-size: 3em; 
    margin: 0; 
    padding: .4em; 
    text-decoration: none; 
    color: #222222; 
    transition: .5s all; 
} 

nav { 
    float: right; 
} 

nav ul { 
    margin: 0; 
    padding: 2.8em 2em; 
} 

nav ul li { 
    display: inline; 
    padding: 0 .4em; 
} 

nav ul li a { 
    color: #222222; 
    text-decoration: none; 
    font-size: 20px; 
    padding-bottom: .5em; 
    transition: .5s color; 
} 

nav ul li a:hover { 
    border-bottom: 3px solid #222222; 
} 

#current { 
    color: #ff4629; 
    border-bottom: 3px solid #222222; 
} 
+2

'。內容爲:{clear:既;}' - 更這裏:https://css-tricks.com/all-about-floats/#article-header-id-2 – sol

+1

因爲你正在使用在div上浮動屬性。您可以使用.content {clear:both}或header {width:100%; float:left;} –

+0

@ovokuro uhhh,這是什麼工作? – Frank

回答

1

添加overflow屬性的頭。

header{overflow: hidden;}