日期:2014-05-17  浏览次数:20818 次

请问div层的问题
请问div层如何使下拉框跟着发送的消息自动下拉,也就是一直处于底端
我已经这样写了
<div   id= "chatcontent "   style= "OVERFLOW-Y:   auto;WIDTH:   100%;POSITION:   relative;HEIGHT:   100%;   display:block;background-color:#ffffcc "> <FONT   face= "宋体 "> </FONT> </div>
已经有overflow-y属性,但这也只是保证在超过高度时候自动出现下拉框,但不能自动下拉一直处于底端,怎么设置阿,请高手解答下

------解决方案--------------------
一着急说错了
chatcontent.scrollTop = chatcontent.scrollHeight - chatcontent.offsetHeight

在div属性里加上
onscroll=window.status= "# "+chatcontent.scrollTop+ "# "+chatcontent.scrollHeight+ "# "+chatcontent.offsetHeight

拖一拖滚动条,看下状态栏就知道咋回事了。
------解决方案--------------------
一直不理解第一句话是什么意思。。。
不过第二句明白了(逗号后的那句),是不是要这效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=utf-8 " />
<style type= "text/css ">
*{
margin: 0;
padding: 0;
}
html{
padding: 0 !important;
height: 100%;
overflow: hidden;
}
body{
width: 800px;
height: 100%;
margin: 0 auto;
overflow: hidden;
}
#sk{
position: absolute;
bottom: 0;
width: 800px;
height: 200px;
background: #ccc;
line-height: 100px;
text-align: center;
}
</style>
<title> </title>
</head>
<body>
<div id= "sk "> 这里是用来放textarea的 </div>
</body>
</html>