保持滚动到底部 [英] Keeping the scroll to bottom

查看:107
本文介绍了保持滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的html是


$ b $我有一个留言框,我想让滚动条保持与IM窗口底部相同。 b

 < div id =shoutContainer> 
< table id =shoutbox>
< tbody>
<! - 此处留言 - >
< / tbody>
< / table>
< / div>

我的css

  #shoutContainer {
height:100px; overflow-y:scroll;
}

如果无法通过html和css。我们可以实现这个原始的JavaScript?因为我没有使用任何框架

解决方案

每当添加项目时,请执行以下操作:

  document.getElementById('shoutContainer')。scrollTop = 10000; 
//或其他大数字

编辑


I have a shoutbox and I want to keep the scroll to bottom same as IM windows.

My html is

<div id="shoutContainer">
            <table id="shoutbox">
                <tbody>
                      <!-- shouts here -->
                </tbody>
            </table>
    </div>

My css

#shoutContainer {
    height: 100px; overflow-y: scroll;
}

If its not possible through html and css. Can we achieve this in raw javascript? because I am not using any framework

解决方案

Whenever an item is added, do the following:

document.getElementById('shoutContainer').scrollTop = 10000;
// or some other big number

edited

这篇关于保持滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆