gpt4 book ai didi

html - 如何将两张 table 放在彼此的顶部,占用相同的宽度

转载 作者:行者123 更新时间:2023-11-28 11:35:53 25 4
gpt4 key购买 nike

我想知道如何将两个表格放在彼此的顶部并占据相同的宽度。

这是示例 html:

<div class="wd100 gridcntnr">
<table class="wd100 bgred">
<tbody>
<tr>
<td>LOREM IPSUM</td>
<td>NAME</td>
<td>ABC</td>
</tr>
</tbody>
</table>
<table class="wd100">
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
<th>Header 5</th>
<th>Header 6</th>
<th>Header 7</th>
<th>Header 8</th>
<th>Header 9</th>
<th>Header 10</th>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
<th>Header 5</th>
<th>Header 6</th>
<th>Header 7</th>
<th>Header 8</th>
<th>Header 9</th>
<th>Header 10</th>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
<th>Header 5</th>
<th>Header 6</th>
<th>Header 7</th>
<th>Header 8</th>
<th>Header 9</th>
<th>Header 10</th>
</tr>

</thead>
<tbody>
</tbody>
</table>
</div>

对应的css为:

.gridcntnr{
overflow:auto;
border: 1px solid black;
}
.wd100{
width: 100%;
}
.bgred{
background-color:red;
}

我想知道为什么两个表的排列方式不同(额外的空间出现在右侧的顶部表中)以及如何将两个表彼此排列并占用相同的宽度.

我尝试使用 table-layout:fixed;但是这样做会导致第二个表变得不合理,并且右侧顶部表中出现的额外空间并未完全删除。

任何帮助将不胜感激。请贡献。

最佳答案

您是否按照以下文档尝试过绝对定位? -> http://www.htmldog.com/guides/css/intermediate/layout/

关于html - 如何将两张 table 放在彼此的顶部,占用相同的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20930513/

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