【发布时间】:2014-04-12 03:19:15
【问题描述】:
您好,我需要为聊天窗口创建一个布局,基本上就像 Facebook 消息页面上的那样:聊天输入文本区域框在窗口底部,消息的滚动内容占据了所有可用空间,看看这些图片:
不缩小:
然后在缩小的时候:
聊天输入文本区域始终位于底部,并且包含消息的滚动 div 的高度发生变化,即使我按 F12 并出现控制台:
现在我的情况几乎相同,这就是我所做的: 我有这个布局:
#top-bar 包含页面的标题,聊天标题是聊天框的标题,messages-chat-container 是包含所有消息的滚动的 div 和 #new-message-chat -container 包含文本区域输入。我需要它总是在底部,所以我写了这个 JQuery:
$(function () {
$(window).resize(function(){
adjustHeight();
});
setTimeout(function() {
adjustHeight();
}, 500);
});
function adjustHeight() {
var header = $("$top-bar");
var headerHeight = getJQElementHeight(header);
$(".content").height($(window).height() - headerHeight);
$("#messages-chat-container").height(getJQElementHeight($(".content")) - getJQElementHeight($("#new-message-chat-container")) );
}
function getJQElementHeight (selector) {
return selector.outerHeight(true);
}
.content 类是一个包含 #chat-head、#messages-chat-container 和 #new-message-chat-container 的类。
但它不起作用,或者更好的是,它起作用了,但 #new-message-chat-container 被剪切了,这意味着它没有全部显示,而只是一部分,我必须向下滚动才能看到它。我想在底部看到所有内容。
我错过了什么?是否有指南或其他东西可以很好地解释这种技术?
【问题讨论】:
标签: javascript jquery css resize chat