[英]Javascript, -100% of viewport not pixel
My problem is simple, but I can't seem to figure it out! 我的问题很简单,但似乎无法解决! My javascript should not deduct 100 pixels, i want 100% of viewport! 我的JavaScript不应扣除100像素,我要100%的视口!
smoothScrollTo(document.getElementById('bottom').offsetTop - 100)
should look like: 应该看起来像:
smoothScrollTo(document.getElementById('bottom').offsetTop - '100%')
but for some reason this is not working. 但是由于某种原因,这是行不通的。
The answer must be in Javascript (cannot use jQuery). 答案必须使用Javascript(不能使用jQuery)。
What about this? 那这个呢?
var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
smoothScrollTo(document.getElementById('bottom').offsetTop - viewportHeight )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.