【问题标题】:Keeping the scroll to bottom保持滚动到底部
【发布时间】:2013-11-13 01:44:52
【问题描述】:

我有一个喊话框,我想保持滚动到底部与 IM 窗口相同。

我的html是

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

我的 CSS

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

如果无法通过 html 和 css 实现。我们可以在原始 javascript 中实现这一点吗?因为我没有使用任何框架

【问题讨论】:

    标签: javascript html css


    【解决方案1】:

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

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

    编辑

    【讨论】:

      【解决方案2】:

      我不确定你是否可以单独使用 CSS,但这里有一个很棒的 jQuery 解决方案:Ajaxdaddy shoutbox

      这是一项免费的喊话框服务,可让您的客户满意:

      Free shoutboxes.

      我只是做了一个以确保没问题,example here

      【讨论】:

      • 我们可以没有框架吗?我不允许使用框架。
      猜你喜欢
      • 1970-01-01
      • 2012-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多