div的水平滚动不起作用
垂直滚动起作用,但水平不起作用。我的代码:div的水平滚动不起作用
<html >
<body >
<table style=" height:100%; width:100%">
<tr>
<td >
<div style=" overflow:scroll; height:100%; width:100%">
<table style=" width:2000px; height:2000px; ">
<tr><td></td></tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>
表不是要使用的理想元素,除非你想显示一个表/目录。 总是比表格更喜欢div。 这应该做乌尔<体>
<div style="height: 100%; width: 100%">
<div style="overflow: scroll; height: 100%; width: 100%">
<table style="width: 2000px; height: 2000px;">
<tr>
<td>
</td>
</tr>
</table>
</div>
随着表中,U必须设置表格的布局里面:固定,
<table style="height: 100%; width: 100%; table-layout:fixed">
<tr>
<td>
<div style="overflow: scroll; height: 100%; width: 100%">
<table style="width: 2000px; height: 2000px;">
<tr>
<td style="width:50%; display:none">
</td>
<td style="width:50%; display:none">
</td>
</tr>
<tr>
<td>control here will auto-align to 50%</td>
<td>control here will auto-align to 50%</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
我已经修改了TD模板。请注意,以及。
我的html是非常大的地方使用大量的表格,为什么它不在表内工作 – 2011-05-10 11:04:55
该表格在差异浏览器中表现不同。因此,对于表格100%的宽度将在某些浏览器中占用100%的容器,而在某些其他浏览器中则占100%。如果你想坚持桌子,你必须告诉浏览器,留在容器中...更新我的解决方案..希望这有助于..(注意:这可能会影响td样式,所以这期望所有的tds是相同的宽度。) – Raghav 2011-05-10 11:20:27
感谢它为我工作 – 2011-05-10 11:42:17
我改变了你这样的代码
<html >
<body >
<table style=" height:100%; width:100%">
<tr>
<td >
<div style=" overflow:scroll; height:2000px; width:100%">
<table style=" width:2000px; height:2000px; overflow:scroll;">
<tr><td></td></tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>
尝试this.it将工作..
您正在尝试表格样式与嵌套表...它永远不会去真的很好。我建议你寻找一个“CSS教程”。在哪个浏览器中使用 – lpd 2011-05-10 10:47:27
?我认为在所有浏览器中工作正常。 – 2011-05-10 10:52:02
互联网浏览器 – 2011-05-10 11:06:41