2

这里我有 2 个表,我希望这 2 个表的宽度相同,当 Confirmer 名称很长时,第二个表扩展但第一个保持不变,我希望它们在任何情况下都具有相同的宽度,如何那能做吗?检查这个JS Bin示例。

HTML:

<table>
<tbody><thead><tr><th>1.5 - STATE</th>
  </tr></thead><tr>
<td>
<b>Issued by </b>User Administrator <b>on</b><font face="verdana" size="1" color="red">           24/05/2013 06:43  
</font></td>
</tr>
</tbody></table>

<table>
<tbody><tr>
<th>
Confirmer
</th>
<th>Status</th>
<th>Date</th>
<th>Comment</th>
</tr>

<tr>
<td>Pathak Chankey</td>
<td>
<img src="xyz.png">
</td>
<td>           24/05/2013 06:43  </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Lastname Firstname</td>
<td>
<img src="xyz.png">
</td>
<td>           24/05/2013 06:43  </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>User Administrator</td>
<td>
<img src="xyz.png">
</td>
<td>         24/05/2013 06:43  </td>
<td>&nbsp;</td>
</tr>
</tbody></table>

CSS:

thead{
  background-color: grey;
}


table, td
{
  background:#fffAF0;
border: 1px solid black;
border-collapse:collapse;
}
4

2 回答 2

3

只需添加一个容器并在您的容器中设置一个宽度,然后将 100% 的宽度应用于您的表格,如下所示

div{

  width:400px;
}

table {

  width:100%;
}

<div>
 <table></table>
 <table></table>
</div>

http://jsbin.com/iduciw/32/edit

于 2013-05-27T05:27:07.360 回答
1

为什么不使用单个表?

<table>
        <tr>
            <th colspan="4">1.5 - STATE</th>
        </tr>       
    <tr>
        <td colspan="4"><b>Issued by </b>User Administrator <b>on</b><font face="verdana" size="1" color="red"> 24/05/2013 06:43 </font></td>
    </tr>
    <tr>
        <th> Confirmer </th>
        <th>Status</th>
        <th>Date</th>
        <th>Comment</th>
    </tr>
    <tr>
        <td>Pathak Chankey</td>
        <td><img src="xyz.png"></td>
        <td> 24/05/2013 06:43 </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>Lastname Firstname</td>
        <td><img src="xyz.png"></td>
        <td> 24/05/2013 06:43 </td>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>User Administrator</td>
        <td><img src="xyz.png"></td>
        <td> 24/05/2013 06:43 </td>
        <td>&nbsp;</td>
    </tr>
</table>
于 2013-05-27T05:25:32.810 回答