HTML5网页设计

导航菜单

CSS+JS实用多级菜单

时间:2014-11-28 22:13来源:未知作者:点击:
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhtml xmlns=http://www.w3.org/1999/xhtml xml:lang=enheadmeta http-equiv=Content-Type content=text/html;charset=UTF-8 /titleCS

<!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" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>CSS+JS实用多级菜单</title>
</head>
<body>
<style type="text/css">
body {
     margin: 7px;     
	 font:12px Verdana, Arial, Helvetica, sans-serif;     
}     
* {
     list-style-type: none;     
	 margin: 0px;     
	 padding: 0px;     
	 border: thin none;     
}     
#nav {    
	 font-size: 9px;     
	 opacity: 0.8;
	 overflow:hidden;    
}     
#nav a {
     display: block;     
	 width: 100px;     
	 height: 15px;     
	 padding: 3px 5px 12px;     
	 background: #666;     
	 color: #fff;     
	 text-decoration: none;     
}     
#nav a:hover {
     background: #333;     
}     
#nav li {
     float: left;     
	 clear: left;     
	 width: 120px;     
	 background: #ccc;     
	 padding-bottom: 3px;     
}     
#nav ul {
     position: absolute;     
	 margin-left: 115px;     
	 margin-top: -30px;     
}     
#nav ul {
     display: none;     
}     
#nav li.show ul {
     display: block;     
}     
#nav li.show li ul {
     display: none;     
}     
#nav li li.show ul {
     display: block;     
}</style>
<script language="javascript" 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? " ": "") + "show";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp("( ?|^)show\\b"), "");
}
}
}
window.onload=menuFix;
</script></fck:meta>
<ul id="nav">
	<li>
		<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com">nav item</a>
		<ul>
			<li>
				<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com">nav item</a>
				<ul>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
				</ul>
			</li>
			<li>
				<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com">nav item</a>
				<ul>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
				</ul>
			</li>
			<li>
				<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com">nav item</a>
				<ul>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
				</ul>
			</li>
			<li>
				<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com">nav item</a>
				<ul>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
					<li>
						<a _fcksavedurl="#" href="#">nav item</a></li>
				</ul>
			</li>
		</ul>
	</li>
	<li>
		<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com">nav item</a>
		<ul>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
		</ul>
	</li>
	<li>
		<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com">nav item</a>
		<ul>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
			<li>
				<a _fcksavedurl="#" href="#">nav item</a></li>
		</ul>
	</li>
</ul>
<p>
	更多代码,请访问:<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com" target="_blank">设计酷</a></p>
</body>
</html>
上一篇:上一篇:没有了 上一篇:下一篇:实用下拉菜单代码
阅完本篇文章?您还可以: 收藏本文 文章挑错 朋友推荐