Reputation: 91
Is it possible to scroll bottom when overflow-y:scroll and height:100vh.
css
#content {
height: 100vh;
overflow-y: scroll;
}
js
var content = document.getElementById('content');
window.scrollTo(0, content.scrollHeight);
codepen https://codepen.io/betchi/pen/zjBwgx
Upvotes: 0
Views: 266
Reputation: 68
You need to use the property scrollTop of the element you want to scroll.
Change your function to this:
function canNotScroll(){
var content = document.getElementById('content');
content.scrollTop = content.scrollHeight;
}
Upvotes: 0
Reputation: 2347
In your example you are scrolling the entire window. It looks like what you want to do is scroll the content and not the window like this:
content.scrollTo(0, content.scrollHeight);
Upvotes: 1