简体   繁体   English

滚动仅自动滚动到DIV的一半

[英]Scroll is auto scrolling only to half of DIV

Friends I'm doing a chat module ih PHP for that I require a Div containing the conversation between the user , Using the jquery I tried to bring the scroll to the bottom of the div but it works only wen the content in the div is low , when it crosses certain limit the scroll stands scrolling on the mid way , I have attached the fiddle of working example here , 朋友,我正在为PHP做一个聊天模块,为此我需要一个Div,其中包含用户之间的对话,我使用jquery尝试将滚动条移到div的底部,但仅在div中的内容很低时才起作用,当它超过一定限度时,滚动架在中途滚动,我在这里附加了工作例子的提琴,

http://jsfiddle.net/jPVAf/50/ http://jsfiddle.net/jPVAf/50/

if u copy paste the following lines 如果您复制粘贴以下行

<p>alskdjg;j ;jhe ;he fkh</p>
<p>alskdjg;j ;jhe ;he fkh</p>
<p>alskdjg;j ;jhe ;he fkh</p>
<p>alskdjg;j ;jhe ;he fkh</p>
<p>alskdjg;j ;jhe ;he fkh</p>

about 600 - 700 lines the scroll will stop in the midway but my requirement is it should scroll even though there is 1000 of records with in it . 大约600至700行,滚动将在中途停止,但是我的要求是即使里面有1000条记录也应该滚动。

尝试更换您的JavaScript 这样

$('div').animate({scrollTop: $('div')[0].scrollHeight});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM