2016-09-17 49 views
1

我在nav中有一個h1段。h2不會從它上面的h1中分離出來

下面我有一個段落的h2。我在一個div中有h2和段落,在另一個div中有h1和navbar,但是h1和h2在一起並且不會分開。如果我用h2和段落標記在div的周圍放置一個邊框,h1和h2周圍的邊框就會出現。正如我已經漂浮了h1和nav,我清楚地知道:在h2上都是這樣,我也試過清楚:兩個都在div上。沒有什麼能夠拉開這兩個元素。我也嘗試了h2的保證金,它是div。

HTML:

<div class="banner"> 

      <h1>JIMMY DAWSON</h1> 


       <ul class="nav"> 
        <li><a href="index.html">Home</a></li> 
        <li><a href="thought.html">Thoughts</a></li> 
        <li><a href="#">Visuals</a></li> 
        <li><a href="#">About</a></li> 
       </ul> 

      </div> 

     <div class="journal-section"> 

     <h2> Headline for the Journal</h2> 

      <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> 

</div> 

CSS:

h2 { 
    clear: both; } 

.journal-section { 
    width: 600px; 
    margin: 30px 30px 0 30px; 
    border: 1px solid red; } 

回答

1

我檢查我browsers這個代碼,我找不到任何問題,讓我說一件事情。當你有HTML工作每個部分都必須像blocks,這將避免許多問題

如:

您可以添加float:left;財產或display:block;

+1

該建議的最後一點幫助。謝謝。儘管如此,在我的瀏覽器(Chrome)上,h2明顯堅持h2。不知道爲什麼其他人都以某種方式看到它,而我看到了另一個。但是顯示:塊清除了問題。再次感謝。 – jwdwsn