我准备做一个div框慢慢从右下角浮上来,但每当我当点上浮时把这个div显示出来(也就是把display改为block)时都会突然出现一部分,这部分是这个div里面的内容称起来的,么样才能去掉,让它从最底下慢慢升起来啊????高手指点下啊
代码:
    <html>
    <head>
    <title>浮框</title>
    <style type="text/css">
    .message
    {
    position:absolute;
    right:0px;
    bottom:0px;
    width:184px;
    height:0px;
    display:none;
    border:1px solid #CCCCCC;
    z-index:10;
    font-size:12px;
    }
    .title
    {
    background-color:#0066CC;
    padding:0 1 0 1;
    cursor:move;
    }
    </style>
    
    <script type="text/javascript">
var obj;
window.onload=function(){
      obj=document.getElementById("kuang");
obj.style.height="0px";
}

    function startup()
    {
      var hand;
      obj.style.display="block";
hand=setInterval(function(){
if(parseInt(obj.style.height)>200)
clearInterval(hand);
else
obj.style.height=(parseInt(obj.style.height)+5);},5);
    }

    function startdown()
    {
    var hand;
hand=setInterval(function(){
if(parseInt(obj.style.height)<5)
{
clearInterval(hand);
obj.style.display="none";
}
else
obj.style.height=(parseInt(obj.style.height)-5);},5);
    }
    </script>
    </head>    <body>
    <div id="kuang" class="message">
    
    <div id="title" class="title">
    仿QQ框
    </div>
    <p>这里输入文章内容</p>
    </div>
    <input type="button" name="button1" onClick="startup()" value="升起" /><br/>
    <input type="button" name="button2" onClick="startdown()" value="下降" />
    </body>
    </html>
    

解决方案 »

  1.   

    我在.message中加了个overflow:hidden,是从最底下出来,但当出来时它还是会出现一下被内容称开的部分(是先出现一下后又消失,然后才从底端出来的),有什么方法可以让它不出现这部分直接从底端出来吗?
      

  2.   

    先在页面的右下角显示div,布局好了后。把他隐藏起来,再要显示的时候直接设置display = block
    即可。当然不一下显示出来就用setTimeout设置坐标left、top即可
      

  3.   

    并不是脚本的问题,而是css没有起作用,要按照标准来写,我试了一下,加上文档声明就行了
    <!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">
      

  4.   

    当然了,overflow:hidden也是要的
      

  5.   

    哦,我试了下可以,但我还想问下,CSS从头到尾一直都没起作用吗?
      

  6.   

    不是的,只是加上文档声明以后浏览器会明白是按照标准来解析,不然的话有部分属性是不能被识别的你可以在页面 初始化的时候让#kuang 显示看看,height:0px是没有起作用的