| 加入收藏

简洁的css下拉菜单代码

2009-06-03 20:45来源: 浏览:[]
所属专题: 网站导航条设计制作  

一款风格简洁的CSS+JS下拉菜单,支持二级子菜单,不过你可将其变为三级,再嵌套一个LI列表就可以完成带3级目录的导航栏设计,颜色你自己改,直到你满意为止。经测试,该下拉菜单在ie浏览器和火狐浏览器中均能正常显示

html+css代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>滑出菜单</title>
<script language="javascript">
startList = function() {
if (document.all && document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>
<style type="text/css">
<!--
body {
font: normal 12px verdana;
}

ul {
margin: 0;
padding: 0;
list-style: none;
width: 150px;
border-bottom: 1px solid #ccc;
}

ul li {
position: relative;
}

li ul {
position: absolute;
left: 149px;
top: 0;
display: none;
}

ul li a {
display: block;
text-decoration: none;
color: #0066cc;
background: skyblue;
padding: 5px;
border: 1px solid #eeeeee;
border-bottom: 0;
}

li:hover ul, li.over ul { display: block; }
-->
</style>
</head>

<body>
<ul id="nav">
<li><a href="http://www.niyun.net">首页</a></li>
<li><a href="#">ASP源码</a>  _fcksavedurl=""#">ASP源码</a> " _fcksavedurl=""#">ASP源码</a> " _fcksavedurl=""#">ASP源码</a> " _fcksavedurl=""#">ASP源码</a> " _fcksavedurl=""#">ASP源码</a> " _fcksavedurl=""#">ASP源码</a> "
<ul>
<li><a href="#">社区论坛</a></li>
<li><a href="http://www.niyun.net">AJAX相关</a></li>
<li><a href="#">精品程序</a></li> _fcksavedurl=""#">精品程序</a></li>" _fcksavedurl=""#">精品程序</a></li>" _fcksavedurl=""#">精品程序</a></li>" _fcksavedurl=""#">精品程序</a></li>" _fcksavedurl=""#">精品程序</a></li>" _fcksavedurl=""#">精品程序</a></li>"
<li><a href="#">CMS建站</a></li>
<li><a href="#">聊天留言</a></li>
</ul>
</li>
<li><a href="#">PHP源码</a>
<ul>
<li><a href="#">新闻文章</a></li>
<li><a href="#">聊天留言</a></li>
<li><a href="#">论坛社区</a></li>
<li><a href="#">图片相册</a></li>
</ul>
</li>
</ul>
</body>
</html>

下拉菜单效果如下:

 

 

 

 

 

热门文章 让并列的div自适应等高的css技巧 以下是作者翻译的内容,是根据我对文章的理解意译的,你就别挑哪里.. 简洁的css下拉菜单代码 这是一款风格简洁的CSS+JS下拉菜单,支持二级子菜单,不过你可将其变.. 用CSS和js控制网页上显示png图片背景透明的方法 通常网页上的背景透明(无背景)的图片都是用gif制作的,如果用png格..


Copyright 2008 逆云网 | 粤ICP备08131116号 |关于我们 | 联系我们 |