Em Sta
Em Sta

Reputation: 1706

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!

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).

Upvotes: 1

Views: 68

Answers (1)

martriay
martriay

Reputation: 5742

What about this?

var viewportHeight = window.innerHeight || document.documentElement.clientHeight;
smoothScrollTo(document.getElementById('bottom').offsetTop - viewportHeight )

Upvotes: 1

Related Questions