gpt4 book ai didi

javascript - 对齐表中的 td

转载 作者:行者123 更新时间:2023-11-28 01:39:41 24 4
gpt4 key购买 nike

下表动态建表时Item6和Item2如何对齐?是否有实现此目的的纯 css 或 css3 方法?

当前表

enter image description here

必填表

enter image description here

<table class="qe">
<tbody>
<tr>
<td>Item1</td>
<td>Item2</td>
<td>Item3</td>
</tr>
<tr>
<td>Item4</td>
</tr>
<tr>
<td>Item5asfasfasf</td>
<td>Item6</td>
</tr>
</tbody>
</table>

fiddle :http://jsfiddle.net/jxvf9arL/1/

最佳答案

正确使用 colspan 属性并删除 table trdisplay:table; 规则,这会扰乱表格布局:

table{
width:500px;
border:1px solid #000;
table-layout:fixed;
}
table td{
width:33%;
border:1px solid #777;
background:#eaeaea;
}
<table class="qe">
<tbody>
<tr>
<td>Item1</td>
<td>Item2</td>
<td>Item3</td>
</tr>
<tr>
<td colspan="3">Item4</td>
</tr>
<tr>
<td>Item5asfasfasf</td>
<td colspan="2">Item6</td>
</tr>
</tbody>
</table>

关于javascript - 对齐表中的 td,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26815450/

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