gpt4 book ai didi

html - 带表格的 DIV 内的水平滚动

转载 作者:太空宇宙 更新时间:2023-11-03 21:43:30 25 4
gpt4 key购买 nike

我在一个 div 中有三个表。当表格的大小增加时,我需要水平和垂直滚动。垂直滚动正在发生,但水平滚动没有发生。第三张 table 在下一行,而不是其他 table 。我使用三个表而不是一个表来进行响应式设计。

<div style="height:250px; width:550px; overflow-x:scroll; overflow-y: scroll; white-space:nowrap;">
<table border="1" style="float:left; table-layout:auto;">
<thead>
<tr>
<th>Pin Number</th>
</tr>
</thead>
<tbody>
<tr>
<td>111111111111111111111111111</td>
</tr>
</tbody>
</table>
<table border="1" style="float:left; table-layout:auto;">
<thead>
<tr>
<th>Pin Number</th>
</tr>
</thead>
<tbody>
<tr>
<td>222222222222222222222222222</td>
</tr>
</tbody>
</table>
<table border="1" style="float:left; table-layout:auto;">
<thead>
<tr>
<th>Pin Number</th>
</tr>
</thead>
<tbody>
<tr>
<td>444444444444444444444444444</td>
</tr>
</tbody>
</table>
</div>

最佳答案

div 包裹每个 table 并使用下面的 css

.wrapper{
height:250px;
width:550px;
overflow:scroll;
white-space:nowrap;
}
.wrapper div{
display:inline-block;
}

DEMO

关于html - 带表格的 DIV 内的水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22006711/

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