JavaScript+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">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
<title>css+javascript下拉菜单系列(四)</title>
<style type="text/css">
body{background-color:#FFFFFF;}
#content{
width:231px;
height:201px;
border:solid 1px #959595;
float:left;
overflow:hidden;
}
.btn_up,.btn_down{
width:231px;
height:26px;
line-height:26px;
font-size:14px;
font-weight:bold;
clear:both;
cursor:pointer;
}
span{
display:block;
margin-left:15px;
}
.btn_up{
background:url(image/sina_music_menu_btn1.gif) transparent scroll no-repeat 0pt 0px;
}
.btn_down{
background:url(image/sina_music_menu_btn2.gif) transparent scroll no-repeat 0pt 0px;
}
.inf{
width:231px;
height:124px;
overflow:hidden;
float:left;
}
ul{
list-style:none outside;
padding:0px;
margin:0px;
}
li{
display:block;
font-size:12px;
color:#333333;
border-bottom:solid 1px #999999;
padding-left:15px;
height:30px;
line-height:30px;
}
.undis{display:none;}
</style>
<script type="text/javascript">
var inf_flag="c";
var btn_flag="btn3"
function funHideShow(x,y){
if(x.className=="btn_up"){
   x.className="btn_down";
   document.getElementById(y).className="inf";
   document.getElementById(btn_flag).className="btn_up";
   funMove(y,inf_flag);
   inf_flag=y; 
   btn_flag=x.id;
}
}
function funMove(m,n){
var objOpen=document.getElementById(m);
var objClose=document.getElementById(n);
var closeH=parseInt(objClose.offsetHeight); 
closeH-=10;
var openH=124-closeH;
if(closeH<=-5){
   objOpen.style.height=124+"px";
   objClose.style.height=0+"px";
   objClose.className="undis";
   return;
}
objOpen.style.height=openH+"px";
objClose.style.height=closeH+"px";
setTimeout("funMove('"+m+"','"+n+"')",50);
}
</script>
</head>

<body>
<div id="content">
<div id="btn1" class="btn_up"οnclick="funHideShow(this,'a');">
   <span>蔡健雅-红色高跟鞋</span>
</div>
<div id="a" class="inf undis">
   <ul>
    <li>
    ·该怎么去形容你最贴切
    </li>
    <li>
    ·拿什么跟你做比较才算特别
    </li>
    <li>
    ·对你的感觉强烈
    </li>
    <li>
    ·却又不太了解 只凭直觉
    </li>
   </ul>
</div>
<div id="btn2" class="btn_up"οnclick="funHideShow(this,'b');">
   <span>蔡健雅-红色高跟鞋</span>
</div>
<div id="b" class="inf undis">
   <ul>
    <li>
    ·你像我在被子里的舒服
    </li>
    <li>
    ·却又像风琢磨不住
    </li>
    <li>
    ·像手纹 像散发的香水味
    </li>
    <li>
    ·像爱不释手的红色高跟鞋
    </li>
   </ul>
</div>
<div id="btn3" class="btn_down"οnclick="funHideShow(this,'c');">
   <span>蔡健雅-红色高跟鞋</span>
</div>
<div id="c" class="inf">
   <ul>
    <li>
    ·我爱你有种左灯右行的冲突
    </li>
    <li>
    ·疯狂却怕没有退路
    </li>
    <li>
    ·你能否让我停止这种追逐
    </li>
    <li>
    ·就这么双 最后唯一的红色高跟鞋
    </li>
   </ul>
</div>
</div>
</body>
</html>

效果描述为,单击一个按钮,在其展开的同时,之前展开的那个区域以同样的速度收缩,这样收缩展开同时进行,总高度又不变,蛮不错的效果。

(该系列完)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值