2012-04-17 130 views
3

您好我想添加這兩個塊之間我的空間: enter image description here如何在我的列表項目之間插入空格?

我目前的顯示器幾乎是正確的,但它不具有塊之間的空間: enter image description here

的代碼是

<div class="data-box"> 
      <div class="personName"><strong>  
       1. Joey Tempest&nbsp; 
      </strong></div> 
     <div class="otherDetails"></div> 

     <table border="0"><tr><td></td><td>Telefon</td><td></td></tr> 
     <tr><td></td><td>Fax</td><td></td></tr> 
     <tr><td></td><td>E-post</td><td></td></tr> 
     <tr><td>Sverige           </td><td>Referens</td><td></td></tr> 
     </table> 


    </div> 

    <div class="clear"></div> 
    <div class="fl10"></div> 



     <div class="data-box"> 
      <div class="personName"><strong>  
       2. Tone Norum&nbsp; 
      </strong></div> 
     <div class="otherDetails"></div> 

     <table border="0"><tr><td></td><td>Telefon</td><td></td></tr> 
     <tr><td></td><td>Fax</td><td></td></tr> 
     <tr><td></td><td>E-post</td><td></td></tr> 
     <tr><td>Sverige           </td><td>Referens</td><td></td></tr> 
     </table> 


    </div> 

我只能插入一個<br>,然後會出現一個空格。這是一個好的解決方案嗎? enter image description here

回答

3

不,添加<br />不是一個好的解決方案。 你應該給下邊距到您的數據框的div:

div.data-box{ 
    margin-bottom: 10px; 
} 

如果你需要的最後一個div不具有裕度,還可以定義它。

這裏是工作提琴(對不起,缺乏德興的,你沒有指定的CSS代碼。) http://jsfiddle.net/DCuKm/1/

+1

這非常好。謝謝。 – 2012-04-17 08:48:50

+0

我認爲 - ':last'在你的小提琴中應該是:':last-child'。 – 2012-04-17 08:55:00

+0

另外請注意,如果你想讓它在IE6-IE8中工作,你應該避免使用'last-child'(參見:http://www.quirksmode.org/css/contents.html)。跨瀏覽器修復只是爲最後一個添加一個額外的類,例如'last'然後將底部邊距設置爲0。 – 2012-04-17 08:57:09

1

爲您的divison添加保證金。

.data-box { 
    margin-bottom: 10px; 
} 
+0

謝謝你的回答。 – 2012-04-17 08:49:12

1

我想你想的底邊增加了data-box的div。

div.data-box { 
    margin-bottom: 5px; 
} 

這通常比休息一個更好的解決方案,因爲它是更加靈活。

請參閱:http://jsfiddle.net/6PZnC/

+0

謝謝你的回答。 – 2012-04-17 08:49:02