js 如何实现div层的下滑,覆盖下面的那个层 求一个问题,如何让蓝色的慢慢的滑下来,然后绿色的也慢慢的滑下去至到消失,蓝色滑至完全覆盖绿色然后停止,蓝色占据绿色原来的位置不显示。(动画效果) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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 type="text/css">#blue{ height:200px; background-color:#00F;}#green{ height:200px; background-color:#0F0;}</style><script type="text/javascript"> function init(){ var b=document.getElementById("blue"); var g=document.getElementById("green"); hides(b,g); } function getHeight(obj){ var style=""; if(document.defaultView&&document.defaultView.getComputedStyle){ style=document.defaultView.getComputedStyle(obj); }else{ style=obj.currentStyle; } return style.height=="auto"?obj.offsetHeight:style.height; } function hides(b,g){ var bw=getHeight(b); var gw=getHeight(g); b.style.height=parseInt(bw)+2+"px"; g.style.height=parseInt(gw)-2+"px"; var p=window.setTimeout(function(){hides(b,g)},100); if(parseInt(gw)==0){ window.clearTimeout(p); } } window.onload=init;</script></head><body><div id="blue"></div><div id="green"></div></body></html>这样试试 <!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 type="text/css">#blue{ height:200px; background-color:#00F; position:relative;}#green{ height:200px; background-color:#0F0;}</style><script type="text/javascript"> function init(){ var b=document.getElementById("blue"); var g=document.getElementById("green"); hides(b,g); } function getTop(obj){ var style=""; if(document.defaultView&&document.defaultView.getComputedStyle){ style=document.defaultView.getComputedStyle(obj); }else{ style=obj.currentStyle; } return style.top=="auto"?obj.offsetTop:style.top; } function hides(b,g){ var bw=getTop(b); var gw=getTop(g); //alert(bw+":"+gw); //b.style.height=parseInt(bw)+2+"px"; //g.style.height=parseInt(gw)-2+"px"; b.style.top=parseInt(bw)+2+"px"; var p=window.setTimeout(function(){hides(b,g)},100); if(parseInt(gw)<=parseInt(bw)+8){ window.clearTimeout(p); } } window.onload=init;</script></head><body><div id="blue"></div><div id="green"></div></body></html>这样试试 问个蛋疼的问题 在线编辑器添加一个功能按钮,点击按钮,使文字加粗加红 如何使不同链接,在同一页显示不同的内容?急!!! 哪个有很多javascript效果的网站是什么 求助!!! 像v111.com的邮件登陆界面! javascript 中文简繁局部互换问题 用winodw.createPopup()创建新窗口是否可以象MSN那样慢慢移出来!!!!!! 请大家帮我看看代码,JS配合层的一个 急:请问如何在不刷新页面的情况下,当一个下拉列表改变时,改变别一个下拉列表的内容 请问元素对象的事件名是否可写成变量,火狐可以,不知道ie如何写 jquery 判断两个字符串是否相似
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#blue{
height:200px;
background-color:#00F;
}
#green{
height:200px;
background-color:#0F0;
}
</style>
<script type="text/javascript">
function init(){
var b=document.getElementById("blue");
var g=document.getElementById("green");
hides(b,g);
}
function getHeight(obj){
var style="";
if(document.defaultView&&document.defaultView.getComputedStyle){
style=document.defaultView.getComputedStyle(obj);
}else{
style=obj.currentStyle;
}
return style.height=="auto"?obj.offsetHeight:style.height;
}
function hides(b,g){
var bw=getHeight(b);
var gw=getHeight(g);
b.style.height=parseInt(bw)+2+"px";
g.style.height=parseInt(gw)-2+"px";
var p=window.setTimeout(function(){hides(b,g)},100);
if(parseInt(gw)==0){
window.clearTimeout(p);
}
}
window.onload=init;
</script>
</head><body>
<div id="blue"></div>
<div id="green"></div>
</body>
</html>这样试试
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#blue{
height:200px;
background-color:#00F;
position:relative;
}
#green{
height:200px;
background-color:#0F0;
}
</style>
<script type="text/javascript">
function init(){
var b=document.getElementById("blue");
var g=document.getElementById("green");
hides(b,g);
}
function getTop(obj){
var style="";
if(document.defaultView&&document.defaultView.getComputedStyle){
style=document.defaultView.getComputedStyle(obj);
}else{
style=obj.currentStyle;
}
return style.top=="auto"?obj.offsetTop:style.top;
}
function hides(b,g){
var bw=getTop(b);
var gw=getTop(g);
//alert(bw+":"+gw);
//b.style.height=parseInt(bw)+2+"px";
//g.style.height=parseInt(gw)-2+"px";
b.style.top=parseInt(bw)+2+"px";
var p=window.setTimeout(function(){hides(b,g)},100);
if(parseInt(gw)<=parseInt(bw)+8){
window.clearTimeout(p);
}
}
window.onload=init;
</script>
</head><body>
<div id="blue"></div>
<div id="green"></div>
</body>
</html>
这样试试