console
var oWords = document.getElementById('talkList');
oWords.scrollTop = oWords.scrollHeight;
$(document).on('click',"input[name=text_value]",function() {
check_list_style();
setTimeout(function() {
window.scrollTo(0, $(".chat-list").height()+999)
}, 500);
oWords.scrollTop = oWords.scrollHeight;
});
$(window).resize(function() {
check_list_style();
setTimeout(function() {
window.scrollTo(0, $(".chat-list").height()+999)
}, 500);
});
function check_list_style()
{
var h = parseInt($('.chat-form').get(0).offsetHeight);
$(".chat-list").css({"margin-bottom" : h + 30 + "px"});
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>中医在线直播</title>
<link rel="stylesheet" href="http://tester.tcmmooc.com/assets/v2/bootstrap/css/bootstrap.css?2.0.1">
</head>
<body>
<div id="talkList" class="chat-list"><p style="height:900px;border:1px solid yellow">聊天内容</p></div>
<div class="chat-form"><input type="text" name="text_value"></div>
<script src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
var oWords = document.getElementById('talkList');
oWords.scrollTop = oWords.scrollHeight;
</script>
</body>
</html>
.chat-list {
padding-bottom: 40px;
padding-top: 16px;
height: 100vh;
background: #f00;
border-bottom:5px solid green;
overflow: auto;
}
.chat-form {
background-color: blue;
padding: 5px;
position: fixed;
bottom: 0;
width: 100%;
max-width: 500px;
z-index: 88;
overflow-y: auto;
overflow-x: hidden;
}