html左侧滑动菜单,JS+CSS实现经典的左侧竖向滑动菜单效果

本文实例讲述了JS+CSS实现经典的左侧竖向滑动菜单效果。分享给大家供大家参考。具体如下:

这是一款经过改造的左侧竖向滑动菜单,基于JavaScript+CSS,没有过多的修饰,主要想实现菜单的动画效果,想用的朋友,自己美化吧。

运行效果截图如下:

f6025dca5db87227168928df874afd8e.png

在线演示地址如下:

具体代码如下:

经过改造的左侧竖向滑动菜单

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;

}

第一层信息

二层

二层

二层

第二层信息

二层

二层

二层

第三层信息

二层

二层

二层

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("没有找到!");

}

}

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("标题和内容数目不相同!");

}

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;

}

希望本文所述对大家的JavaScript程序设计有所帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值