|

升级   2.67% - 注册时间
- 2006-1-5
- 威望
- 25
- 阅读权限
- 20
- 积分
- 54
- 帖子
- 25
- 精华
- 0
- UID
- 45417
- 状态
- 当前离线
|
楼主要的是这种效果吧?
- <div id="mydiv" style="width:200px;border:1px solid green">
- 航班延迟,我成了机场最后抵达的一批旅客。辉煌的灯火,一盏一盏熄灭在我身后,当走出机场的那一刻。
- 热闹的机场,原来,也有寂寞的时候。人去楼空,我回眸与机场对望,带着相互了解的心情。曲终人散,它以寂寥的街灯对应。
- 差点回不了家的,还是在最后一秒赶上了最后一班飞机。登机前,我把所有的喜悦、疲惫、忧伤……等沉重的行李一一卸下,决心以幸福的姿势飞翔。
- 随身携带的,唯有真爱。
- </div>
- <input type=button value="collapse" onclick="accordionCollapse(mydiv)"><input type=button value="expand" onclick="accordionExpand(mydiv)">
- <script>
- /**
- *滑动闭合
- *@param {Object} 要闭合的div,diplay必须为""
- *
- */
- function accordionCollapse(o)
- {
- if(o.processaccordion) return;
- if(o.style.display=="none") return;
- o.processaccordion=true;
- var tmpnode=o.nextSibling;
- if(tmpnode==null||!tmpnode.isAccordion)
- {
- tmpnode=document.createElement("div");
- tmpnode.isAccordion=true;
- tmpnode.style.overflow="hidden";
- var parentNode=o.parentNode;
- parentNode.insertBefore(tmpnode,o.nextSibling);
- }
- //alert(o.offsetWidth+":"+o.clientWidth)
- tmpnode.style.width=o.offsetWidth;
- tmpnode.style.height=o.offsetHeight;
- tmpnode.style.display="";
- o.style.width=o.clientWidth;
- o.style.position='absolute';
- var step=1;
- setTimeout(function(){return accordionIn.apply(o,[{'div':tmpnode,'acc':o,'height':o.offsetHeight,'progress':0,'step':step}])},41)
- }
- /**
- *滑动展开
- *@param {Object} 要展开的div,diplay必须为none
- *
- */
- function accordionExpand(o)
- {
- if(o.processaccordion) return;
- if(o.style.display!="none") return;
- o.processAccoridion=true;
- var tmpnode=o.nextSibling;
- if(tmpnode==null||!tmpnode.isAccordion)
- {
- tmpnode=document.createElement("div");
- tmpnode.isAccordion=true;
- var parentNode=o.parentNode;
- tmpnode.style.overflow="hidden";
- parentNode.insertBefore(tmpnode,o.nextSibling);
- }
- o.style.display="";
- o.style.width=o.clientWidth;
- o.style.position='absolute';
- tmpnode.style.width=o.offsetWidth;
- tmpnode.style.height=0;
- tmpnode.style.display="";
- var height=o.offsetHeight;
- var step=5;
- var tl=5;
- while(true)
- {
- tl=tl+step*3
- if(tl>=height) {break;}
- else
- step=step*3;
- }
- var s=height-(tl-step*3);
- tmpnode.style.height=s;
- o.style.marginTop=s*-1;
- o.style.clip="rect("+s+" auto auto auto)";
- setTimeout(function(){return accordionOut.apply(o,[{'div':tmpnode,'acc':o,'height':height,'progress':s,'step':step}])},41)
- }
- function accordionIn(o)
- {
- o.progress=o.progress+o.step;
- if(o.step<12)
- o.step=o.step+1
- else
- o.step=o.step*3;
- o.acc.style.clip="rect("+o.progress+" auto auto auto)";
- o.acc.style.marginTop=o.progress*-1;
- if(o.height-o.progress<0)
- o.div.style.display="none";
- else
- o.div.style.height=o.height-o.progress;
- if(o.progress>=o.height)
- {
- o.acc.style.display="none"
- o.div.style.display="none";
- o.acc.processaccordion=false;
- // o.div.parentNode.removeNode(o.div,true);
- }
- else
- setTimeout(function(){return accordionIn.apply(o,[o])},41)
- }
- function accordionOut(o)
- {
- if(o.height-o.progress<=5) {
- o.progress=o.progress+1;
- }
- else
- {
- o.progress=o.progress+o.step;
- o.step=o.step/3;
- }
- o.acc.style.clip="rect("+(o.height-o.progress)+" auto auto auto)";
- o.acc.style.marginTop=o.progress-o.height;
- o.div.style.height=o.progress;
- if(o.progress>=o.height)
- {
- o.acc.style.position="static";
- o.div.style.display="none"
- o.acc.processaccordion=false;
- return;
- }
- else
- setTimeout(function(){return accordionOut.apply(o,[o])},41)
- }
- </script>
复制代码运行代码另存代码
[[I] 本帖最后由 goldduck 于 2008-7-2 17:11 编辑 [/I]] |
|