gpt4 book ai didi

html - 如何使 html 表格滚动条在 chrome 浏览器中支持?

转载 作者:行者123 更新时间:2023-11-28 06:54:14 29 4
gpt4 key购买 nike

我需要你的帮助。我有一个包含许多列的 HTML 表格。我已经使用 css 制作了适合 table 和笔记本电脑屏幕的水平滚动条,它在 firefox 中得到支持,我想知道为什么我的 css 滚动条编码在 chrome 浏览器中不受支持?

这是我的CSS

table.scroll {
table-layout: fixed;
display: block;
overflow-x: scroll;
}

这是我的 html 代码示例(这只是示例,因为我的表中有超过 15 列

<table class="scroll">
<tr>
<td>aaaaaaa</td>
<tr>
</table>

感谢您的帮助...(我需要知道这一点,因为一些会使用我的 html 表格的人正在使用 chrome 浏览器)

最佳答案

首先,您需要确保关闭 <tr></tr>正确标记。

水平滚动条确实适用于 chrome,但您必须设置表格宽度,以便当您的数据溢出 x 轴时您可以滚动一些内容。

让我举例说明:

HTML:

<table class="scroll">
<tr>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
<td>aaaaaaa</td>
</tr>
</table>

CSS:

  table.scroll {
table-layout: fixed;
display: block;
overflow-x: scroll;
max-width: 100px;
}

CODEPEN DEMO

关于html - 如何使 html 表格滚动条在 chrome 浏览器中支持?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33602133/

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