最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

javascript仿qq界面的折疊菜單實(shí)現(xiàn)代碼

 更新時(shí)間:2012年12月12日 10:22:05   作者:  
最近一直在研究網(wǎng)頁特效,看到qq界面的折疊菜單,于是冒出個(gè)想法,自己寫一個(gè)類似的,需要的朋友可以參下
最近一直在研究網(wǎng)頁特效,看到qq界面的折疊菜單,于是冒出個(gè)想法,自己寫一個(gè)類似的,上網(wǎng)查了一下,發(fā)現(xiàn)已經(jīng)有不少類似的菜單效果,不管那么多,先寫著再說吧.

以下是html結(jié)構(gòu):
<div id="a"><div id="h1">sdfds</div><div id="b1">dsfdsfsdfsd</div><div id="h2">dsf</div><div id="b2">dsfdsfsdf</div>.......................</div>
id為a里的便是你要添加的菜單的標(biāo)題和內(nèi)容.

下面是javascript代碼:
復(fù)制代碼 代碼如下:

sx.activex.packmenu={
create:function(t){
var a=document.createElement("div");
var _t=t;
a.style.height="300px";
a.style.width="150px";
a.style.border="1px red solid";
a.style.overflow="hidden";
for(var i=0;i<t.length;i++){
var h=document.createElement("div");
var b=document.createElement("div");;
h.style.backgroundColor="blue";
h.style.height="10%";
b.style.padding="5px";
b.style.textAlign="center";
b.style.border="1px green solid";
h.innerHTML=t[i][0];
b.innerHTML=t[i][1];
b.style.overflow="hidden";
b.style.height="0px";
b.style.display="none";
h.onclick=function(){
if(this.nextSibling.style.display=="none"){
this.nextSibling.style.height="1px";
this.nextSibling.style.display="block";
this.h=window.setInterval(function(t,t1){
return function(){
if(!t1) return;
//alert(t.nextSibling.offsetHeight);
if(parseInt(t.nextSibling.style.height)<100-_t.length*parseInt(a.all[0].style.height)-3){
t.nextSibling.style.height=parseInt(t.nextSibling.style.height)+3+"%";
t1.style.height=parseInt(t1.style.height)-3+"%";
}
else{
t.nextSibling.style.height=100-_t.length*parseInt(a.all[0].style.height)+"%";;
t1.style.display="none";
t1.style.height="0px";
window.clearInterval(t.h);
}
}
}(this,(function(){
for(var ii=0;ii<a.all.length;ii++){
if(parseInt(a.all[ii].style.height)>10)
return a.all[ii];
}
})()),10);
}
else{
if(this!=this.parentNode.firstChild){
this.previousSibling.style.height="1px";
this.previousSibling.style.display="block";
}
else{
this.parentNode.lastChild.style.display="block";
this.parentNode.lastChild.style.height="1px";
}
this.h=window.setInterval(function(t,t1){
return function(){
if(!t1) return;
if(parseInt(t.nextSibling.style.height)>3){
if(t!=t.parentNode.firstChild)
t.previousSibling.style.height=parseInt(t.previousSibling.style.height)+3+"%";
else
t.parentNode.lastChild.style.height=parseInt(t.parentNode.lastChild.style.height)+3+"%";
t1.style.height=parseInt(t1.style.height)-3+"%";


}
else{
if(t!=t.parentNode.firstChild)
t.previousSibling.style.height=100-_t.length*parseInt(a.all[0].style.height)+"%";
else
t.parentNode.lastChild.style.height=100-_t.length*parseInt(a.all[0].style.height)+"%";
t.nextSibling.style.display="none";
t.nextSibling.style.height="0px";
window.clearInterval(t.h);
}
}
}(this,(function(){
for(var ii=0;ii<a.all.length;ii++){
if(parseInt(a.all[ii].style.height)>10)
return a.all[ii];
}
})()),1);
}
}
a.appendChild(h);
a.appendChild(b);
a.all[1].style.display="block";
a.all[1].style.height=100-t.length*parseInt(a.all[0].style.height)+"%";
}
return a;
}
}

入口參數(shù)t是你要傳遞的二維數(shù)組,以一個(gè)標(biāo)題加內(nèi)容為一個(gè)數(shù)組項(xiàng)的形式:
下面是調(diào)用代碼:
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<script src="kongjian.js" ></script>
<script>
var a=sx.activex.packmenu.create([["asd","sadsadas"],["sd","sadsaas"],["w","waedqwdq"],["e","efwefw"]]);
//a.contentEditable=true;
document.body.appendChild(a);
</script>
</body>
</html>
搞定,有興趣的朋友可以看下效果.

相關(guān)文章

最新評(píng)論

梁平县| 新河县| 阜南县| 兰溪市| 麻江县| 久治县| 延庆县| 台北县| 馆陶县| 达尔| 河曲县| 天镇县| 大连市| 霍州市| 那坡县| 东安县| 上林县| 淮北市| 井陉县| 永德县| 应城市| 二连浩特市| 会同县| 德昌县| 苍山县| 历史| 陆丰市| 尚志市| 临洮县| 永新县| 乌鲁木齐市| 伊吾县| 巨野县| 洛隆县| 宜丰县| 固镇县| 广河县| 平昌县| 平安县| 措勤县| 团风县|