JS實(shí)現(xiàn)的左側(cè)豎向滑動(dòng)菜單效果代碼
本文實(shí)例講述了JS實(shí)現(xiàn)的左側(cè)豎向滑動(dòng)菜單效果代碼。分享給大家供大家參考,具體如下:
這是一款經(jīng)過(guò)改造的左側(cè)豎向滑動(dòng)菜單,基于JavaScript+CSS,沒(méi)有過(guò)多的修飾,主要想實(shí)現(xiàn)菜單的動(dòng)畫(huà)效果,想用的朋友,自己美化吧。
運(yùn)行效果截圖如下:
在線演示地址如下:
http://demo.jb51.net/js/2015/js-left-scroll-style-menu-demo/
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <title>經(jīng)過(guò)改造的左側(cè)豎向滑動(dòng)菜單</title> <style type="text/css"> body{ margin:10px; padding:10px; } a:link { text-decoration: none;color: blue} a:active { text-decoration:blink} a:hover { text-decoration:underline;color: red} a:visited { text-decoration: none;color: green} body,td,div,span,li{ font-size:12px; } .title01,.title02{ color:#00b; font-weight:bold; } #DoorP{ width:200px; height:300px; padding:0px; background:#FFFCF2; } .title01{ width:100%; height:25px; background:#FFFCF2; cursor:pointer; } .title02{ width:100%; height:25px; background:#FFFCF2; cursor:pointer; } .content{ background:#FFFCF2; border-bottom:2px solid #fff; overflow:hidden; color:#666; padding-left:4px; padding-right:4px; line-height:18px; } .curved { width:202px; } .curved .b1, .curved .b2, .curved .b3, .curved .b4 { font-size:1px; display:block; background:#FFFCF2; overflow: hidden; } .curved .b1, .curved .b2, .curved .b3 { height:1px; } .curved .b2, .curved .b3, .curved .b4 { background:#FFFCF2; border-left:1px solid #C7BC98; border-right:1px solid #C7BC98; } .curved .b1 { margin:0 4px; background:#C7BC98; } .curved .b2 { margin:0 2px; border-width:0 2px; } .curved .b3 { margin:0 1px; } .curved .b4 { height:2px; margin:0; } .curved .c1 { margin:0 5px; background:#C7BC98; } .curved .c2 { margin:0 3px; border-width:0 2px; } .curved .c3 { margin:0 2px; } .curved .c4 { height:2px; margin: 0 1px; } .curved .boxcontent { display:block; background:transparent; border-left:1px solid #C7BC98; border-right:1px solid #C7BC98; font-size:0.9em; text-align:justify; } </style> <div class="curved"> <b class="b1 c1"></b> <b class="b2 c2"></b> <b class="b3 c3"></b> <b class="b4 c4"></b> <div class="boxcontent"> <div id="DoorP"> <table> <tr> <td align="center"> 第一層信息 </td> </tr> </table> <div class="content" align="center"> <a href="#">二層</a><br/> 二層<br/> 二層<br/> </div> <b class="b1"></b> <b class="b2"></b> <b class="b3"></b> <b class="b4"></b> <table> <tr> <td align="center"> 第二層信息 </td> </tr> </table> <div class="content" align="center"> <a href="#">二層</a><br/> 二層<br/> 二層<br/> </div> <b class="b1"></b> <b class="b2"></b> <b class="b3"></b> <b class="b4"></b> <table> <tr> <td align="center"> 第三層信息 </td> </tr> </table> <div class="content" align="center"> <a href="#">二層</a><br/> 二層<br/> 二層<br/> </div> </div></div> <b class="b4 c4"></b> <b class="b3 c3"></b> <b class="b2 c2"></b> <b class="b1 c1"></b> <script type="text/javascript"> var open = 2; var openState = new Array(); var closeState = new Array(); var dH = 220; function $(id){ if(document.getElementById(id)) { return document.getElementById(id); } else { alert("沒(méi)有找到!"); } } function $tag(id,tagName){ return $(id).getElementsByTagName(tagName) } function closeMe(Cid,Oid){ var h = parseInt(Ds[Cid].style.height); //alert(h); if(h > 2) { h = h - Math.ceil(h/3); Ds[Cid].style.height = h+"px"; } else { openMe(Oid); clearTimeout(closeState[Cid]); return false; } closeState[Cid] = setTimeout("closeMe("+Cid+","+Oid+")"); } function openMe(Oid){ var h = parseInt(Ds[Oid].style.height); //alert(h); if(h < dH) { h = h + Math.ceil((dH-h)/3); Ds[Oid].style.height = h+"px"; } else { clearTimeout(openState[Oid]); return false; } openState[Oid] = setTimeout("openMe("+Oid+")"); } var Ds = $tag("DoorP","div"); var Ts = $tag("DoorP","table"); if(Ds.length != Ts.length) { alert("標(biāo)題和內(nèi)容數(shù)目不相同!"); } for(var i = 0 ; i < Ds.length ; i++) { if(i==open) { Ds[i].style.height = dH+"px"; Ts[i].className="title01"; } else { Ds[i].style.height = "0px"; Ts[i].className="title02"; } Ts[i].value = i; Ts[i].onclick = function(){ if(open==this.value) { return false; } Ts[open].className="title02"; Ts[this.value].className="title01"; for(var i = 0 ; i < openState.length ; i++) { clearTimeout(openState[i]); clearTimeout(closeState[i]); } closeMe(open,this.value); //openMe(this.value); open = this.value; } } function showDiv(id){ Ds[id].style.height=dH+"px"; Ds[open].style.height="0px"; open = id; } </script>
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
- vue.js 左側(cè)二級(jí)菜單顯示與隱藏切換的實(shí)例代碼
- javascript仿京東導(dǎo)航左側(cè)分類導(dǎo)航下拉菜單效果
- JS實(shí)現(xiàn)新浪博客左側(cè)的Blog管理菜單效果代碼
- JS+CSS實(shí)現(xiàn)經(jīng)典的左側(cè)豎向滑動(dòng)菜單效果
- js實(shí)現(xiàn)的后臺(tái)左側(cè)管理菜單代碼
- 原生JS實(shí)現(xiàn)仿淘寶網(wǎng)左側(cè)商品分類菜單效果代碼
- js實(shí)現(xiàn)的四級(jí)左側(cè)網(wǎng)站分類菜單實(shí)例
- js左側(cè)三級(jí)菜單導(dǎo)航實(shí)例代碼
- js左側(cè)多級(jí)菜單動(dòng)態(tài)的解決方案
- JavaScript實(shí)現(xiàn)左側(cè)菜單效果
相關(guān)文章
JavaScript實(shí)現(xiàn)離開(kāi)頁(yè)面前提示功能【附j(luò)Query實(shí)現(xiàn)方法】
這篇文章主要介紹了JavaScript實(shí)現(xiàn)離開(kāi)頁(yè)面前提示功能,結(jié)合具體實(shí)例形式分析了javascript實(shí)現(xiàn)針對(duì)關(guān)閉頁(yè)面的事件響應(yīng)原理與操作技巧,并附帶jQuery的相應(yīng)實(shí)現(xiàn)方法,需要的朋友可以參考下2017-09-09比JSON.stringify快兩倍的fast-json-stringify性能對(duì)比分析
這篇文章主要為大家介紹了比JSON.stringify快兩倍的fast-json-stringify性能對(duì)比分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12JS實(shí)現(xiàn)控制表格只顯示行邊框或者只顯示列邊框的方法
這篇文章主要介紹了JS實(shí)現(xiàn)控制表格只顯示行邊框或者只顯示列邊框的方法,涉及javascript使用表格對(duì)象的rules屬性的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03List Information About the Binary Files Used by an Applicati
List Information About the Binary Files Used by an Application...2007-06-06js改變html的原有內(nèi)容實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇js改變html的原有內(nèi)容實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-10-10使用原生js+canvas實(shí)現(xiàn)模擬心電圖的實(shí)例
下面小編就為大家?guī)?lái)一篇使用原生js+canvas實(shí)現(xiàn)模擬心電圖的實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-09-09按鍵測(cè)試,支持像 Ctrl+Alt+Shift+T 的組合鍵
按鍵測(cè)試,支持像 Ctrl+Alt+Shift+T 的組合鍵...2006-10-10javascript(jquery)利用函數(shù)修改全局變量的代碼
現(xiàn)在博客系統(tǒng)的評(píng)論遇到一個(gè)問(wèn)題,用戶點(diǎn)擊“最后一頁(yè)”鏈接之后就自動(dòng)調(diào)取最后一頁(yè)的資料來(lái)顯示。2009-11-11