滚动到div的底部?

假如想象 提交于 2020-04-26 19:14:02

问题:

I am creating a chat using ajax requests in rails and I'm trying to get a div to scroll to the bottom without much luck. 我正在使用Rails中的Ajax请求创建聊天,并且试图使div滚动到底部没有太多运气。

I am wrapping everything in this div: 我将所有内容包装在这个div中:

#scroll {
    height:400px;
    overflow:scroll;
}

Is there a way to keep it scrolled to the bottom by default using JS? 有没有一种方法可以使用JS将其默认滚动到底部?

Is there a way to keep it scrolled to the bottom after an ajax request? 是否有办法在ajax请求后将其滚动到底部?


解决方案:

参考一: https://stackoom.com/question/18Oi/滚动到div的底部
参考二: https://oldbug.net/q/18Oi/Scroll-to-bottom-of-div
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!