zccst整理
为方便直接使用,两个代码如下
(一)截图
[img]http://dl.iteye.com/upload/attachment/0067/4022/2294246f-430e-3f03-a833-0ee6cd128e92.jpg[/img]
代码
(二)
截图
[img]http://dl.iteye.com/upload/attachment/0067/4026/e4df84d7-6c74-3129-a359-84c5a5799fc1.jpg[/img]
代码
为方便直接使用,两个代码如下
(一)截图
[img]http://dl.iteye.com/upload/attachment/0067/4022/2294246f-430e-3f03-a833-0ee6cd128e92.jpg[/img]
代码
<!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>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script type="text/javascript"><!--//--><![CDATA[//><!--
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{
text-align: center;
font-size:12px;
font-family:"宋体";
}
#popimg{
WIDTH:770px;
margin:0 auto;
text-align:center;
}
#popimg2{
WIDTH:770px;
margin:0 auto;
text-align:center;
z-index:-1;
}
ul {
padding: 0;
margin: 0;
list-style: none;
}
li {
position:relative;
float: left;
width: 110px;
}
li ul {
position:absolute;
display: none;
top: 20px;left:0;
}
li:hover ul, li.over ul {
display: block;
}
ul li a{
display:block;
font-size:12px;
border: 1px solid #ccc;
padding:3px;
margin-right:1px;
text-decoration: none;
color: #777;background:#eee;
}
ul li a:hover{
background-color:#f4f4f4;
}
#test{
clear:both;
background-color:#999999;
width:769px;
height:100px;
margin:0 auto;
}
</style>
</head>
<body>
<div id="popimg">
<ul id="nav">
<li><a href="">文章</a>
<ul>
<li ><a href="">CSS教程</a> </li>
<li ><a href="">DOM教程</a></li>
<li ><a href="">XML教程</a></li>
<li ><a href="">Flash教程</a></li>
</ul>
</li>
<li><a href="">参考</a>
<ul>
<li><a href="">XHTML</a></li>
<li><a href="">XML</a></li>
<li><a href="">CSS</a></li>
</ul>
</li>
<li><a href="">博客</a>
<ul>
<li><a href="">全部</a></li>
<li><a href="">网页技术</a></li>
<li><a href="">UI技术</a></li>
<li><a href="">FLASH技术</a></li>
</ul>
</li>
<li><a href="">文章</a>
<ul>
<li ><a href="">CSS教程</a> </li>
<li ><a href="">DOM教程</a></li>
<li ><a href="">XML教程</a></li>
<li ><a href="">Flash教程</a></li>
</ul>
</li>
<li><a href="">参考</a>
<ul>
<li><a href="">XHTML</a></li>
<li><a href="">XML</a></li>
<li><a href="">CSS</a></li>
</ul>
</li>
<li><a href="">博客</a>
<ul>
<li><a href="">全部</a></li>
<li><a href="">网页技术</a></li>
<li><a href="">UI技术</a></li>
<li><a href="">FLASH技术</a></li>
</ul>
</li>
<li><a href="">博客</a>
<ul>
<li><a href="">全部</a></li>
<li><a href="">网页技术</a></li>
<li><a href="">UI技术</a></li>
<li><a href="">FLASH技术</a></li>
</ul>
</li>
</ul>
</div>
<div id="popimg2">
<div id="test"></div>
</div>
</body>
</html>
(二)
截图
[img]http://dl.iteye.com/upload/attachment/0067/4026/e4df84d7-6c74-3129-a359-84c5a5799fc1.jpg[/img]
代码
<!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" lang="zh-CN">
<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-family: arial, 宋体, serif;
font-size:12px;
}
#contain{ margin:0px auto; width:1003px; background:#CCCCCC; position:relative;}
#nav {
line-height: 24px; list-style-type: none; background:#666;
}
#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 {
float: left; 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: 980px; position: absolute; float:left;
}
#nav li ul li{
float: left; width: 80px;
background: #F6F6F6;
}
#nav li ul a{
display: block; width: 80px;text-align:center;
}
#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 {
margin-left:0px;
}
#nav li.sfhover ul {
left: 0;
}
#content {
clear: left;
}
-->
</style>
<script type=text/javascript><!--//--><![CDATA[//><!--
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>
<div id="contain">
<ul id="nav">
<li><a href="#">菜单一级</a>
<ul>
<li><a href="#">菜单一级</a></li>
<li><a href="#">菜单一级</a></li>
<li><a href="#">菜单一级</a></li>
<li><a href="#">菜单一级</a></li>
<li><a href="#">菜单一级</a></li>
<li><a href="#">菜单一级</a></li>
</ul>
</li>
<li><a href="#">菜单二级</a>
<ul>
<li><a href="#">菜单二级</a></li>
<li><a href="#">菜单二级</a></li>
<li><a href="#">菜单二级</a></li>
<li><a href="#">菜单二级服</a></li>
<li><a href="#">菜单二级</a></li>
<li><a href="#">菜单二级</a></li>
</ul>
</li>
<li><a href="#">菜单三级</a>
<ul>
<li><a href="#">菜单三级</a></li>
<li><a href="#">菜单三级</a></li>
<li><a href="#">菜单三级</a></li>
<li><a href="#">菜单三级</a></li>
</ul>
</li>
<li><a href="#">菜单四级</a>
<ul>
<li><a href="#">菜单四级</a></li>
<li><a href="#">菜单四级</a></li>
<li><a href="#">菜单四级</a></li>
<li><a href="#">菜单四级</a></li>
<li><a href="#">菜单四级</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>