2
我有一個表蒙山許多div
的IT上面:長表滾動,但阻止窗口滾動
<div></div>...<div></div>
<div id="tablecontent">
<table>...</table>
</div>
我想我表滾動只在屏幕上(表格的底部是在窗口的底部)。所以我需要爲#tablecontent
設置高度和scroll=auto
。 要設置heigth我計算的話爲:
var pos=$("#tablecontent").position().top;
var heigth=$(window).height()-pos;
$("#tablecontent").css("height",heigth+'px');
但這不能正常工作。它比我需要的大。你能幫我計算正確的價值嗎?
額外的高度很可能來自邊緣或周圍元素的父母填充。它只是一個伸出窗外的底部填充物嗎? – user3297291