长表滚动,但阻止窗口滚动

时间:2016-03-22 16:13:28

标签: javascript jquery html

我的桌子上面有许多div

<div></div>...<div></div>
<div id="tablecontent">
<table>...</table>

</div>

我希望我的桌子只在屏幕上滚动(桌子的底部位于窗口的底部)。所以我需要为scroll=auto设置身高和#tablecontent。 要设置高度,我将其计算为:

var pos=$("#tablecontent").position().top;
var heigth=$( window ).height()-pos;
$("#tablecontent").css("height",heigth+'px');

但这不能正常工作。它比我需要的大。你能帮我计算一下正确的价值吗?

1 个答案:

答案 0 :(得分:1)

在您的CSS中的div上,您想设置overflow: scroll,当内容大于div时,具有固定高度的内容会在System.set(System.normalizeSync('config'), System.newModule({ foo: 'bar' })); // in the real scenario the { foo: 'bar' } is rendered by the server 上创建一个滚动条容器。