我准备做一个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>
代码:
<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>
即可。当然不一下显示出来就用setTimeout设置坐标left、top即可
<!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">