日期:2014-05-16 浏览次数:20768 次
<!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" />
<title>无标题文档</title>
<style>
*{ margin:0; padding:0;}
.div{ position:relative;width:980px;height:50px; float:left;margin-top:500px;margin-left:100px;}
.D1{width:50px; height:50px; background:#CCC;}
.D2{width:100px; height:100px; background:#066; position:absolute;top:-120px;left:-30px;
display:none;}
</style>
<script>
window.onload=function ()
{
/* var oDiv1=document.getElementById('div1');
var oDiv2=document.getElementById('div2');
var Time=null;
oDiv1.onmouseover=oDiv2.onmouseover=function(){
clearTimeout(Time);
oDiv2.style.display='block';
}
oDiv1.onmouseout=oDiv2.onmouseout=function(){
Time=setTimeout(function(){
oDiv2.style.display='none';
},500)
}*/
var oDiv = document.getElementById('div1');
oDiv.onmouseover = function () {
startMove(100);
}
oDiv.onmouseout = function () {
startMove(50);
}
};
//创建运动框架
var timer=null;
function startMove(iTarget){//创建目标
var oDiv1=document.getElementById('div2');
clearInterval(timer)//关闭定时器
timer=setInterval(function(){//开启定时器
var speed=0;
if(iTarget==100){
speed=10;
}else{
speed=-10;
}
if(oDiv1.offsetHeight==iTarget){
clearInterval(timer);
}else{
oDiv1.style.height=oDiv1.offsetHeight+speed+'px';
}
},30)
}
</script>
</head>
<body>
<div class="div">
<div class="D1" id="div1"></div>
<div class="D2" id="div2"></div>
</div>
</body>
</html>
//创建运动框架
var timer=null;
function startMove(iTarget){//创建目标
var oDiv1=document.getElementById('div2');
clearInterval(timer)//关闭定时器
timer=setInterval(function(){//开启定时器
var speed=0;
if(iTarget==100){
speed=10;
}else{
speed=-10;
}
if(oDiv1.offsetHeight==iTarget){