快捷搜索:

DIV+CSS构成的树型菜单

这是用DIV+CSS+JS构成的树型菜单,采纳列表,相符WEB标准,在大年夜多半WIN浏览器下,兼容性不错,xhtml见效果页,我现在做的是二个菜单,假如必要添加,可把......之间的内容加上去,"submenuid"加1,查看效果。

CSS代码

body {

margin: 0px;

padding: 0;

font: 12px "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;

background: #FFFFFF;

text-align: center;

}

ul{

margin: 0;

padding: 0;

list-style: none;

}

#treenav {

margin: 10px;

text-align: left;

}

#treenav ul li {

margin: 1px 0;

padding: 0;

font-size: 11px;

}

#treenav ul.eanded {

display: block;

}

#treenav ul.eanded,#treenav ul.collapsed {

margin: 5px 10px;

}

#treenav ul.collapsed {

display: none;

}

.eanded li,.collapsed li{

border-bottom: 1px dashed #CCCCCC;

width: 100px;

}

.listhead {

font-weight: bold;

display: block;

font-size: 12px;

color: #333333;

background: #F1F1F1;

padding: 3px;

width: 120px;

margin: 1px 0;

}

#treenav a {

text-decoration: none;

color: #666666;

}

#treenav a:hover {

color: #990000;

}

JS代码

function toggleMenu(id){

element = document.getElementById(id);

element.className = (element.className.toLowerCase() == 'eanded'?'collapsed':'eanded');

}

onload = function() {

toggleMenu('submenuid');

}

您可能还会对下面的文章感兴趣: