html css div宽度不相对于子表

时间:2014-01-27 09:40:19

标签: html css

我希望一张表在div中具有相对宽度。如果一个表有一个大图片或长字,怎么做,所以同一个div中的其他表也扩展到100%作为第一个。 请参见示例:

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

2 个答案:

答案 0 :(得分:0)

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

但必须是言语,而不仅仅是“aaaaaaaaaaaaddddddddddd”。

答案 1 :(得分:0)

仅回答问题,

    display: table;

对于'外部'div将会这样做。