发送新邮件时,聊天框不会完全向下滚动

时间:2017-04-17 04:48:10

标签: javascript jquery html css

所以我正在使用html,css,php和JS创建一个类似应用程序的聊天框。我偶然发现了一个问题,点击进入按钮后我会运行

 $("#MESSAGES").scrollTop($("#MESSAGES")[0].scrollHeight);

(#MESSAGES是我的聊天室日志的ID)然后该消息就会显示它并显示在屏幕上但不会滚动到。虽然它向下滚动但它没有完全向下滚动以显示新的消息,除非我再次点击进入。 无论如何,我只需点击回车键,并在输入按钮后右侧显示消息底部的消息?

.chatbox {
  width: 700px;
  max-width: 590px;
  height: 600px;
  background-color: white;
  margin: 20px auto;
  padding: 20px;
  padding-right: none;
  box-shadow: 0 15px 20px -10px rgba(0, 0, 0, 0.3);
}

这是div的样式,其中保留了消息(消息日志)。

.chatlogs {
  padding: 10px;
  width: 100%;
  height: 450px;
  overflow: auto;
}

这是消息出现的实际div。

非常感谢您提前:))

0 个答案:

没有答案
相关问题