分数滚动高度? [英] Fractional scrollHeight?
本文介绍了分数滚动高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
https://developer.mozilla.org/en -US / docs / Web / API / element.scrollHeight :
此属性将值舍入为整数。如果您需要小数值,请使用
element.getBoundingClientRect()
。
除了...... element.getBoundingClientRect()
不返回scrollHeight。怎么会得到一个小数scrollHeight?有可能吗?
Except... element.getBoundingClientRect()
does not return the scrollHeight. How would one get a fractional scrollHeight? Is it possible?
推荐答案
我想我可能有解决方案:
I think I might have the solution:
var rect = element.getBoundingClientRect()
var scrollHeight = element.scrollHeight + (parseInt(rect.height) - rect.height)
var scrollWidth = element.scrollWidth + (parseInt(rect.width) - rect.width)
这篇关于分数滚动高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文