在移动浏览器(Android,Safari,Chrome,Firefox)中滚动div块而不是窗口滚动

时间:2013-09-10 09:33:58

标签: css scroll height overflow infinite-scroll

我必须滚动div块而不是窗口滚动,我希望这个块直到页面结束,如果它更长,则滚动 - 它必须出现。

我有这样的HTML:

<body>
    <div id='header'>
    </div>
    <div id='content'>
        <div id='main'>
            <div id='options'>
            </div>
            <!-- other blocks -->
            <div id='scrorable'> <!-- This div i want to scroll instead of window -->
                <table>
                </table>
            </div>
        </div>
    </div>
</body>

我也使用无限滚动,现在可以在窗口滚动中使用:

$(window).scroll(function()
{
    if($(window).scrollTop() >= $(document).height() - $(window).height() - 200)
    {
        //ajax Call and append income data to html 
    }
});

我还需要根据滚动div(不是窗口)更改此代码。

已更新:我以这种方式销售的无限滚动问题:

在我的滚动div中插入一个内部div:

<div id='scrorable'>
    <div id='scrorable-inner'> <!--My inner div-->
        <-- content -->
        <table>
        </table>
    </div>                    
</div>

我改变了内部滚动码:

$('div#scrorable').scroll(function()
{
        if($('div#scrorable').scrollTop() >= $('div#scrorable-inner').height() - $'div#scrorable').height() - 200)
        {
            //ajax Call and append income data to html 
        }
});

已更新

现在我用

  $('div#scrorable').height($(window).height()-300); 

设置该块的高度。我使用($(window).height() - 页眉和页脚的高度(300px))

0 个答案:

没有答案