gpt4 book ai didi

javascript - overflow-y :scroll and height:100vh 时如何滚动底部

转载 作者:太空宇宙 更新时间:2023-11-04 07:24:22 25 4
gpt4 key购买 nike

overflow-y:scroll height:100vh 是否可以滚动到底部

CSS

#content {
height: 100vh;
overflow-y: scroll;
}

js

var content = document.getElementById('content');
window.scrollTo(0, content.scrollHeight);

代码笔 https://codepen.io/betchi/pen/zjBwgx

最佳答案

在您的示例中,您正在滚动整个窗口。看起来你想要做的是滚动内容而不是像这样的窗口:

content.scrollTo(0, content.scrollHeight);

关于javascript - overflow-y :scroll and height:100vh 时如何滚动底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50022072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com