国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

帶緩沖的 收縮與展開內(nèi)容效果

2019-11-21 01:55:21
字體:
供稿:網(wǎng)友
兼容ie5.5+   firefox2.0(因為我只有這兩個瀏覽器,所以只在它們中做了測試)

看到blueidea很多朋友都發(fā)了一些 收縮與展開內(nèi)容的效果,唯一差的就是一個緩沖效果.不多說,運行一下就知道了,呵呵.
最大高度還需要固定數(shù)值.沒有很好的解決方案.有興趣的朋友幫忙解決一下拉,謝謝.
這個代碼其他部分不會再發(fā)出更新和完善之后的了.如果需要封裝就自己做做吧,呵呵.

放出代碼為分享學(xué)習(xí)之用.請尊重別人的作品勿作商業(yè)用途!!!!!
復(fù)制代碼 代碼如下:

<html>
<head>
<script>
/*
By Auntion
QQ 82874972
歡迎喜歡javascript 和 ajax的朋友++我QQ,大家共同進(jìn)步,呵呵
使用方法
調(diào)用效果: Effect(1,2);
  其中1為: 被改變對象的id
  其中2為: 控制容器的id  可在使用:  this.parentNode.id  取得(父標(biāo)簽的id)
注意給對象ID的時候一定不要重復(fù).
*/
function $G(Read_Id) { return document.getElementById(Read_Id) }
function Effect(ObjectId,parentId){
    if ($G(ObjectId).style.display == 'none'){
    Start(ObjectId,'Opens');
    $G(parentId).innerHTML = "<a href=# onClick=javascript:Effect('"+ObjectId+"','"+parentId+"');>關(guān)閉</a>"
    }else{ 
    Start(ObjectId,'Close');
    $G(parentId).innerHTML = "<a href=# onClick=javascript:Effect('"+ObjectId+"','"+parentId+"');>打開</a>"
    }
}
function Start(ObjId,method){
var BoxHeight = $G(ObjId).offsetHeight;               //獲取對象高度
var MinHeight = 5;                                    //定義對象最小高度
var MaxHeight = 130;                                 //定義對象最大高度
var BoxAddMax = 1;                                    //遞增量初始值
var Every_Add = 0.15;                                //每次的遞(減)增量  [數(shù)值越大速度越快]
var Reduce = (BoxAddMax - Every_Add);
var Add    = (BoxAddMax + Every_Add);
if (method == "Close"){
var Alter_Close = function(){                        //構(gòu)建一個虛擬的[遞減]循環(huán)
    BoxAddMax /= Reduce;
    BoxHeight -= BoxAddMax;
    if (BoxHeight <= MinHeight){
        $G(ObjId).style.display = "none";
        window.clearInterval(BoxAction);
    }
    else $G(ObjId).style.height = BoxHeight;
}
var BoxAction = window.setInterval(Alter_Close,1);
}
else if (method == "Opens"){
var Alter_Opens = function(){                        //構(gòu)建一個虛擬的[遞增]循環(huán)
    BoxAddMax *= Add;
    BoxHeight += BoxAddMax;
    if (BoxHeight >= MaxHeight){
        $G(ObjId).style.height = MaxHeight;
        window.clearInterval(BoxAction);
    }else{
    $G(ObjId).style.display= "block";
    $G(ObjId).style.height = BoxHeight;
    }
}
var BoxAction = window.setInterval(Alter_Opens,1);
}
}
</script>
<style>
body,div,table { font-size:12px;}
#control{ width:200; background-color:#ccc; font-size:12px; font-color:#333333; text-align:center; }
#control a { font-weight:900; line-height:30px; color:#333333; }
.test{ height:130;width:200;background-color:#ccc;display:block;overflow:hidden; }
.STYLE1 {
    font-size: 8px;
    color: #FFFFFF;
}
</style>
</head>
<body>
<div id="control">
  <table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="100%" align="center" bgcolor="#2DD5FF" id="testtab"><a href="#" onClick="Effect('test',this.parentNode.id);">關(guān)閉</a></td>
    </tr>
  </table>
</div>
<div id="test" class="test">
  <table width="100%" height="130" border="0" cellpadding="4" cellspacing="0" bgcolor="#EEEEEE">
    <tr>
      <td colspan="3" align="center" valign="top">這<br>
        里<br>
        是<br>
        第<br>
        二<br>
        ,<br>
        很<br>
        正<br>
        常<br></td>
    </tr>
  </table>
</div>
<div id="control">
  <table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="100%" align="center" valign="bottom" bgcolor="#00C0F0"><span class="STYLE1">▲</span></td>
    </tr>
  </table>
</div>
<br>
<div id="control">
  <table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="100%" align="center" bgcolor="#2DD5FF" id="test1tab"><a href="#" onClick="Effect('test1',this.parentNode.id);">關(guān)閉</a></td>
    </tr>
  </table>
</div>
<div id="test1" class="test">
  <table width="100%" height="130" border="0" cellpadding="4" cellspacing="0" bgcolor="#EEEEEE">
    <tr>
      <td colspan="3" align="center" valign="top">這<br>
        里<br>
        是<br>
        第<br>
        一<br>
        ,<br>
        很<br>
        正<br>
        常<br></td>
    </tr>
  </table>
</div>
<div id="control">
  <table width="100%" height="10" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="100%" align="center" valign="bottom" bgcolor="#00C0F0"><span class="STYLE1">▲</span></td>
    </tr>
  </table>
</div>
</body>
</html>

兩個都關(guān)閉的狀態(tài)

[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]

一個打開一個關(guān)閉的狀態(tài)

[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]

美化下的

[Ctrl+A 全選 注:如需引入外部Js需刷新才能執(zhí)行]
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 诏安县| 民和| 吉隆县| 汉中市| 南京市| 潮安县| 平陆县| 和硕县| 清河县| 东乡县| 秀山| 彩票| 岫岩| 牙克石市| 屯昌县| 普兰县| 曲麻莱县| 沙河市| 个旧市| 澎湖县| 塔城市| 云霄县| 哈巴河县| 南开区| 鹤山市| 莱芜市| 鞍山市| 宁海县| 嘉义市| 甘泉县| 汉沽区| 涞水县| 吉林省| 温州市| 西昌市| 南城县| 越西县| 台湾省| 尉氏县| 吉木乃县| 高邑县|