gpt4 book ai didi

html - 使 HTML 表格单元格中的文本与其他单元格重叠

转载 作者:搜寻专家 更新时间:2023-10-31 22:28:13 24 4
gpt4 key购买 nike

我想在一个单元格中放置一些较长的文本,以便在下一个单元格中重叠而不是换行,但又不会使第一列变大。

enter image description here

如果我给手机

white-space: nowrap;
position: absolute;

它将位于正确的位置,但其他文本将在其下方流动。

感谢您的快速回答。

最佳答案

可以通过设置overflow:visible,防止换行,设置固定宽度,让一个单元格的内容流入同一行的其他单元格,这也需要固定的表格布局。你还需要为表格设置一个固定的宽度,否则浏览器不会进行固定的表格布局。

<style>
.x {
width: 3em;
white-space: nowrap;
overflow: visible;
color: red;
}
table {
table-layout: fixed;
}
th:nth-child(1) { width: 3em; }
th:nth-child(2) { width: 15em; }
th:nth-child(3) { width: 2em; }
th:nth-child(4) { width: 7em; }
th:nth-child(5) { width: 3em; }
</style>
<table border cellspacing=0>
<thead>
<th>nr<th>name<th>year<th>category<th>price
<tbody>
<tr>
<td><div class=x>A longer line that should not wrap , but go over the other cells</div></td>
<td><td><td><td>
<tr>
<td>999.0
<td>Some name
<td>2000
<td>Some category
<td>135.32
</table>

这太复杂了,您可能应该按照@MikeW 的建议进行操作,这不会使单元格内容溢出到其他单元格,而是使单元格跨越所有五列。

关于html - 使 HTML 表格单元格中的文本与其他单元格重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27902281/

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