当我想在 colspan
中使用百分比将 3 个单元格的表格中的 2 个单元格分成两半时,我在使用表格时遇到了问题,但出现了错误。现在表格中的所有其他 colspans
都没有宽度而且一团糟,我不能在 3 个单元格行中使用百分比,因为它将是一个奇数这里是代码:
<table style="table-layout:fixed;" border="1" width="100%">
<tr>
<td colspan="100%">Notify</td>
</tr>
<tr>
<td colspan="25%">Store</td>
<td colspan="75%">Logo</td>
</tr>
<tr>
<td colspan="100%">Discount</td>
</tr>
<tr >
<td>Summer</td>
<td>Discounts</td>
<td>Fashion</td>
</tr>
<tr >
<td colspan="50%">News1</td>
<td colspan="50%">News2</td>
</tr>
<tr>
<td colspan="100%">News 3</td>
</tr>
<tr>
<td colspan="100%">News 4</td>
</tr>
</table>
最佳答案
这不是 colspan 的工作方式。您应该改用宽度。
属性 colspan 接受一个数字,而不是百分比,并告诉表格单个 TD 应该跨越多少列。
例如:
<tr>
<td width="50%">News1</td>
<td width="50%">News2</td>
</tr>
<tr>
<td colspan="2">News 3</td>
</tr>
<tr>
<td colspan="2">News 4</td>
</tr>
关于html - Colspan Bug 同时使用百分比和数字时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25403544/