gpt4 book ai didi

html - 表格行的不同宽度

转载 作者:太空宇宙 更新时间:2023-11-03 22:49:13 24 4
gpt4 key购买 nike

我尝试拆分中间行并保持上行和底部不变。

<table border="1" width="500">
<tbody>
<tr bgcolor="red">
<td width="10%">&nbsp;</td>
<td width="80%">&nbsp;</td>
<td width="10%">&nbsp;</td>
</tr>
<tr bgcolor="green">
<td width="50%" colspan="2">&nbsp;</td>
<td width="50%">&nbsp;</td>
</tr>
<tr bgcolor="blue">
<td colspan="3">&nbsp;</td>
</tr>
</tbody>
</table>

如何使用一个表格标签将中间行分成两列?

最佳答案

添加更多colspan:

table {
width: 500px;
table-layout: fixed;
border: 1px outset;
}
tr:nth-child(1) > td:nth-child(2) {
width: 80%;
}
td::after {
content: '\200B'; /* Insert zero-width space */
}
table { border: 1px outset; }
td { border: 1px inset; }
tr:nth-child(1) { background: red; }
tr:nth-child(2) { background: green; }
tr:nth-child(3) { background: blue; }
<table>
<tbody>
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="4"></td>
</tr>
</tbody>
</table>

关于html - 表格行的不同宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40830825/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com