我正在尝试让表格的宽度与屏幕大小相同,溢出应该是滚动条,而不是整个页面都有滚动条。
目前以下代码为整个页面生成滚动条,而不是仅为表格生成滚动条。
感谢任何帮助。
我有生成动态长度的表
<table width="100%" style="overflow:none">
<tr>
for 1 ... n
<td></td>
</tr>
</table>
end for
最佳答案
为您正在使用的页面提供一个 ID,并为该 ID 提供 overflow:hidden。这样其他页面仍然可以在它们的主体中溢出。参见 DEMO
body{
width:100%,
overflow: hidden;
}
div.scrollWrapper{
height:250px;
overflow:scroll;
}
div.scrollWrapper table{
width:100%;
}
关于具有 100% 溢出滚动的 HTML 表格,仅适用于表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22796100/