2

我在这里阅读了一些关于如何获取滚动条高度的主题,以及“使用百分比”的答案。但是没有错误的最佳计算方法是什么?

数学“错误”是已知的,例如 10 / 15 = 0.666666,这个问题会返回奇怪的滚动条高度......所以最好的方法是避免这种情况,并获得百分比

高度 = x% from scrollHeight ?

谢谢你。

4

1 回答 1

-2
$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document
$(window).width();   // returns width of browser viewport
$(document).width(); // returns width of HTML document

screen.height; //for screen height
screen.width; //for screen width

在你的情况下

$(window).height(); // length y s.bar
$(window).width(); // length x s.bar
于 2013-08-25T12:51:39.737 回答