请教一个打开/关闭层的问题
<p ><strong>cain</strong> 发表于 2010-2-4 09:55</p>
<h3>请教一个打开/关闭层的问题</h3><!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=gb2312" />
<title>js</title>
<style type="text/css">
body,span,div,td{font-size:12px;line-height:1.5em;color:#849BCA;}
#bodyL{
float:left;
width:84px;
margin-right:2px;
}
a.od{
width:80px;
height:25px;
line-height:25px;
text-align:center;
font-weight:bold;
border: 2px solid #849BCA;
display:block;
color:#547BC9;
float:left;
text-decoration:none;
margin-top:2px;
}
a.od:link{
background:#EEF1F8;
}
a.od:visited{
background:#EEF1F8;
}
a.od:hover{
background:#EEE;
}
a.od:active{
background:#EEE;
}
#fd{
width:500px;
height:200px;
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:80px;
margin-left:2px;
float:left;
overflow:hidden;
position:absolute;
left:0px;
top:0px;
cursor:move;
float:left;
}
#fd1{
width:500px;
height:200px;
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:80px;
margin-left:200px;
float:left;
overflow:hidden;
position:absolute;
left:0px;
top:0px;
cursor:move;
float:left;
}
.content{
padding:10px;
}
</style>
</head>
<body>
<div id="bodyL">
<a href="http://bbs.pqshow.com/#" class="od" onclick = "show('fd');return false;">
[打开层1]
</a>
<a href="http://bbs.pqshow.com/#" class="od" onclick = "closeed('fd');return false;">
[关闭层1]
</a>
</div>
<div id="fd" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="content">test1</div>
</div>
<div id="bodyL">
<a href="http://bbs.pqshow.com/#" class="od" onclick = "show('fd1');return false;">
[打开层2]
</a>
<a href="http://bbs.pqshow.com/#" class="od" onclick = "closeed('fd1');return false;">
[关闭层2]
</a>
</div>
<div id="fd1" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="content">test2</div>
</div>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id){/*--打开--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,500)},10);
}
function openx(o,x){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,200)},10);
}
}
function openy(o,y){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id){/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--关闭y--*/
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){/*--关闭x--*/
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}
</script>
</body>
</html>
以上这段是在网上找来的动画打开/关闭层的代码,请问要怎么修改才能让一个层打开的时候同时关闭(或者隐藏)其他层(也就是当前打开的层永远只有一个)?
急用,谢谢!!<p ><strong>chineseweapon</strong> 发表于 2010-2-4 11:27</p>
<h3>你看下是要这个效果么?</h3>你看下是要这个效果么?
<!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=gb2312" />
<title>js</title>
<style type="text/css">
body,span,div,td{font-size:12px;line-height:1.5em;color:#849BCA;}
#bodyL{
float:left;
width:84px;
margin-right:2px;
}
a.od{
width:80px;
height:25px;
line-height:25px;
text-align:center;
font-weight:bold;
border: 2px solid #849BCA;
display:block;
color:#547BC9;
float:left;
text-decoration:none;
margin-top:2px;
}
a.od:link{
background:#EEF1F8;
}
a.od:visited{
background:#EEF1F8;
}
a.od:hover{
background:#EEE;
}
a.od:active{
background:#EEE;
}
#fd0{
width:500px;
height:200px;
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:80px;
margin-left:2px;
float:left;
overflow:hidden;
position:absolute;
left:0px;
top:0px;
cursor:move;
float:left;
}
#fd1{
width:500px;
height:200px;
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:80px;
margin-left:200px;
float:left;
overflow:hidden;
position:absolute;
left:0px;
top:0px;
cursor:move;
float:left;
}
.content{
padding:10px;
}
</style>
</head>
<body>
<div id="bodyL">
<a href="http://bbs.pqshow.com/#" class="od" onclick = "show('fd',0,2);return false;">
[打开层1]
</a>
<a href="http://bbs.pqshow.com/#" class="od" onclick = "closeed('fd',0,2);return false;">
[关闭层1]
</a>
</div>
<div id="fd0" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="content">test1</div>
</div>
<div id="bodyL">
<a href="http://bbs.pqshow.com/#" class="od" onclick = "show('fd',1,2);return false;">
[打开层2]
</a>
<a href="http://bbs.pqshow.com/#" class="od" onclick = "closeed('fd',1,2);return false;">
[关闭层2]
</a>
</div>
<div id="fd1" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="content">test2</div>
</div>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id,cur,num){/*--打开--*/
for(i=0;i<num;i++){
document.getElementById(id+i).style.display="none";
}
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id+cur);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,500)},10);
}
function openx(o,x){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,200)},10);
}
}
function openy(o,y){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id,cur,num){/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id+cur);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--关闭y--*/
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){/*--关闭x--*/
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}
</script>
</body>
</html>
[ 本帖最后由 chineseweapon 于 2010-2-4 11:45 编辑 ]<p ><strong>cain</strong> 发表于 2010-2-4 12:32</p>
原帖由 chineseweapon 于 2010-2-4 11:27 发表 http://bbs.blueidea.com/images/common/back.gif
你看下是要这个效果么?
js
body,span,div,td{font-size:12px;line-height:1.5em;color:#849BCA;}
#bodyL{
float:left;
width:84px;
margin-right:2px;
}
a.od{
width:80px;
height: ...
就是这样的!!非常感谢!!!^_^~
页:
[1]