gpt4 book ai didi

css - Firefox 如何在单元格表格内显示滚动条?

转载 作者:太空宇宙 更新时间:2023-11-04 09:40:07 25 4
gpt4 key购买 nike

这是最简单的代码,仍然突出了 Firefox 的行为(在 Chrome 和 IE 中,滚动条按预期显示)

<html>
<body>
<table style="width:100%; height:100%;">
<tbody>
<tr>
<td style=" width: 75%; height: 100%; vertical-align: top; background-color: #FFE4C4;">
<div style=" width: 100%; height: 100%; overflow: auto;">
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
<div> 1 __________________ line </div>
</div>
</td>

<td style="background-color: #DEB887;"> <div> . </div> </td>
</tr>

</tbody>
</table>
</body>
</html>

有任何提示让它即使在 FF 中也能正常工作吗?非常感谢

最佳答案

您使用的结构不符合您的要求。表格和表格单元格的主要功能是根据内容进行扩展,因此最好为此使用不同的布局样式,例如高度为 100% 的相对父项和其中绝对定位的子项100% 高度和 overflow:auto

这就是说,您要实现的目标如下:

a) 首先添加html, body到height:100%b) 对表格使用table-layout:fixedc) 使用 height:100% 到 trd) 在 td 中使用 display:inline-block div(这是为了 ie 工作)e) 使用带有 overflow:auto 的绝对定位元素。

这是一个有效的 fiddle : https://jsfiddle.net/Ls6go1g4/

关于css - Firefox 如何在单元格表格内显示滚动条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40004335/

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