2014-01-27 29 views
0

我想要一個表格在div中具有相對寬度。如果一張桌子有一張大圖或一個長字,如何做,所以同一div中的其他表也可以作爲第一張。 請例子中看到的:html css的div寬度不是相對於子表格

CSS

.outer { 
    border: solid 3px green; 
    width: 100%; 
    display: block; 
} 
table { 
    border: solid 1px red; 
    width: 100%; 
} 
.label { 
    border: solid 3px red; 
    width: 20%; 
} 

HTML

<div class="outer"> 
     <table > 
     <tr> 
      <td class="label"> 
       Label 01 
      </td>   
      <td> 
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq s 
      </td> 
     </tr> 
     <tr> 
      <td class="label"> 
       Label 02 
      </td>     
      <td> 
    meworks & Extensionsotools More 1.3.1 (compat) 
    ART 0.8.7 PowerTools 1.0.5 Fiddle Options External Resources 
    Languages Results Ajax RequestsLegal, Credits and Links 
      </td> 
     </tr>  
     </table> 
    </div> 

這裏是我的Demo

+0

你的小提琴嚇到我了....你可以改述你想要什麼? – NoobEditor

+2

請勿使用表格進行佈局。 –

回答

0

爲了回答剛纔的問題,

display: table; 

的 '外' 的div就行了。

0
table td {word-wrap: break-word;} 

但一定要的話,不只是 「aaaaaaaaaaaadddddddddd」。