2013-06-01 26 views
0

即時通訊使用div而不是表格,但iam沒有得到邊框增加,而內容在列中增加。由div標籤在html中的表格結構

<div class="divTable"> 
      <div class="headRow"> 
       <div class="divCell" align="center">Customer ID</div> 
       <div class="divCell">Customer Name</div> 
       <div class="divCell">Customer Address</div> 
      </div> 
      <div class="divRow"> 
        <div class="divCell">001</div> 
       <div class="divCell">002</div> 
       <div class="divCell">am unable to get the white space between col while the content increases</div> 
      </div> 
      <div class="divRow"> 
       <div class="divCell">xxx</div> 
       <div class="divCell">yyy</div> 
       <div class="divCell">www</div> 
      </div> 
      <div class="divRow"> 
       <div class="divCell">ttt</div> 
       <div class="divCell">uuu</div> 
       <div class="divCell">Mkkk</div> 
      </div> 

     </div> 

.divTable{ 
    display:table;   
    width:auto;   
    background-color:#eee;   
    border:1px solid #666666;   
    border-spacing:5px; 
} 
.divRow{ 
    display:table-row; 
    width:auto; 
    clear:both; 
    background-color:#ccc; 
} 
.divCell{ 
    float:left; 
    display:table-column;   
    width:100px;   
border-left: 2px solid #fff; 
} 

親切經過波紋管鏈接: http://jsfiddle.net/vasanthanvas/H4Zug/

+2

這看起來像一個表格數據,爲什麼div的使用,而不是表? –

+0

@ Mr.Alien如果您想爲表格設置動畫效果,對div進行動畫製作比對一行或一個單元格更容易。例如,可以滑入和滑出的行 – Danielo515

回答

4

必須使用display:table-cell代替display:table-column和刪除float:left.divCell

並添加此風格:

.headRow{ 
    display:table-row; 
} 

http://jsfiddle.net/4Y6cJ/3/