https://developer.mozilla.org/en-US/docs/Web/API/element.scrollHeight :
This property will round the value to an integer. If you need a fractional value, use
element.getBoundingClientRect()
.
除了... element.getBoundingClientRect()
不返回 scrollHeight。如何获得小数的 scrollHeight?可能吗?
最佳答案
我想我可能有解决方案:
var rect = element.getBoundingClientRect()
var scrollHeight = element.scrollHeight + (parseInt(rect.height) - rect.height)
var scrollWidth = element.scrollWidth + (parseInt(rect.width) - rect.width)
关于javascript - 小数滚动高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21666892/