当前位置:编程学习 > JS >>

CSS 竖排折叠菜单

CSS 竖排折叠菜单,简洁明快,配合JS共同打造,高手们可以再完善一下。
答案:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>css菜单</title>
<style type="text/css">
<!--
*{margin:0;padding:0;border:0;}
body {
        font-size:12px;
}
#nav {
  line-height: 24px;  list-style-type: none; background:#666;   width:80px;
}

#nav a {
 display: block; width: 80px; text-align:center;
}

#nav a:link  {
 color:#666; text-decoration:none;
}
#nav a:visited  {
 color:#666;text-decoration:none;
}
#nav a:hover  {
 color:#FFF;text-decoration:none;font-weight:bold;
}

#nav li {
width: 80px; background:#CCC;
}
#nav li a:hover{
 background:#999;
}
#nav li ul {
 line-height: 27px;  list-style-type: none;text-align:left;
 left: -999em; width: 80px; position: absolute; 
}
#nav li ul li{
 float: left; width: 80px;
 background: #F6F6F6; 
}


#nav li ul a{
 display: block; width: 80px;w\idth:56px;text-align:left;padding-left:24px;
}

#nav li ul a:link  {
 color:#666; text-decoration:none;
}
#nav li ul a:visited  {
 color:#666;text-decoration:none;
}
#nav li ul a:hover  {
 color:#F3F3F3;text-decoration:none;font-weight:normal;
 background:#C00;
}

#nav li:hover ul {
 left: auto;
}
#nav li.sfhover ul {
 left: auto;position:static;
}
#content {
 clear: left; 
}


-->
</style>
<script type=text/javascript><!--
function menuFix() {
 var sfEls = document.getElementById("nav").getElementsByTagName("li");
 for (var i=0; i<sfEls.length; i++) {
  sfEls[i].onmouseover=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseDown=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseUp=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onmouseout=function() {
  this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 

"");
  }
 }
}
window.onload=menuFix;
--></script>
</head>
<body>
<ul id="nav">
<li><a href="#">微软中国</a>
 <ul>
 <li><a href="#">最新更新</a></li>
 <li><a href="#">下载排行</a></li>
 </ul>
</li>
<li><a href="#">最新更新</a>
 <ul>
 <li><a href="#">DELPHI</a></li>
 <li><a href="#">VC++</a></li>
 <li><a href="#">AJAX</a></li>
 </ul>
</li>
<li><a href="#">广告服务</a>
 <ul>
 <li><a href="#">服务条款</a></li>
 </ul>
</li>
<li><a href="/">在线演示</a>
 <ul>
 <li><a href="/">JQUERY</a></li>
 <li><a href="#">AJAX</a></li>
 <li><a href="#">EXTJS</a></li>
 </ul>
</li>
<li><a href="/">代码编程</a>
 <ul>
 <li><a href="#">ASP</a></li>
 <li><a href="#">PHP</a></li>
 <li><a href="#">JSP</a></li>
 </ul>
</li>
</ul>
</body>
</html>

上一个:TAB标签选项卡(CSS+JS)
下一个:极酷的CSS导航特效

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,