代码简介:

一级横向滑动,二级竖向下拉综合菜单,这个菜单一共是三级,前两级是滑动切换的方式,第三级主要是下拉菜单的形式,虽然简单的样式简约,但是实现他们其实是很复杂的,希望从事前端开发的朋友一同参考一下吧。

代码内容:

View Code
<!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>【荐】JS+CSS全力打造的一级横向滑动,二级竖向下拉综合菜单_网页代码站(http://www.webdm.cn)%3c/title>
<style type="text/css">
<!--
body,ul,ol,li,dl,dt,dd,h1{ margin:0; padding:0; list-style:none;}
body { font:12px "Arial","宋体";color:#333;background:#FFF;}
a{border:none; text-decoration:none;}
#menu { width:980px; margin:30px auto;}
 #menu dl { padding-left:10px; height:30px;overflow:hidden; }
 #menu dl dd { float:left; padding-right:5px;}
 #menu dl dd a {display:block; padding-left:10px; background:url("http://www.webdm.cn/images/20110110/menu.gif") no-repeat 0 -60px;}
 #menu dl dd a span {
  display:block;
  color:#630;
  width:50px;
  height:30px;
  text-align:center;
  line-height:34px;
  font-size:14px;
  padding-right:10px;
  background:url("http://www.webdm.cn/images/20110110/menu.gif") no-repeat right -60px;
  overflow:hidden;
 }
 #menu dl dd a:hover,
 #menu dl dd.ok a { background-position: 0 -90px;}
 #menu dl dd a:hover span,
 #menu dl dd.ok a span { cursor:pointer; font-weight:bold; color:#FFF;background-position: right -90px;}
 
 #menu ol {clear:both; height:30px; background:url("http://www.webdm.cn/images/20110110/menu.gif") repeat-x 0 0;}
 #menu ol li { float:left;}
 #menu ol li a { color:#FFF; display:block; width:70px; text-align:center; height:30px; line-height:32px; overflow:hidden;}
 #menu ol li a:hover,
 #menu ol li.ok a,
 #menu ol li.ol a{ font-weight:bold; background:url("http://www.webdm.cn/images/20110110/menu.gif") no-repeat 0 -30px;}
 
 #menu ol li span { width:150px;position:absolute;background-color:#FEFEFE;}
 #menu ol li span h1 {font:12px "宋体"; float:none; display:block; background-color:#E6E6E6;}
 #menu ol li span h1 a,
 #menu ol li.ok span h1 a,
 #menu ol li.ok span ul a{
  color:#333;
  width:148px;
  text-indent:10px;
  height:24px;
  line-height:26px;
  text-align:left;
  font-weight:normal;
  border-top:#FFF 1px solid;
  border-bottom:#A0A0A0 1px solid;
  border-right:#A0A0A0 1px solid;
  background-image:none;
 }
 #menu ol li span h1 a:hover,
 #menu ol li span h1.ok a {color:#930; font-weight:bold; background-image:none; background-color:#D9D9D9;}
 #menu ol li.ok span ul {width:147px; border:#E6E6E6 1px solid; border-top:none;overflow:hidden;}
 #menu ol li.ok span ul a {border:none;}
 #menu ol li.ok span ul a:hover { color:#930; font-weight:bold; text-indent:15px; background-image:none;}
.no,.ol span { display:none;}
-->
</style>
<script language="javascript">
<!--//
function ShowMenu(obj,n){
 var dd = obj.parentNode.getElementsByTagName("dd");
 for(var i=0;i<dd.length;i++){dd[i].className = "";}
 dd[n].className = "ok";
 var ol = document.getElementById("menu").getElementsByTagName("ol");
 for(var i=0;i<ol.length;i++){ol[i].className = "no";}
 ol[n].className = "";
}
function ShowSpan(obj,n){
 var span = obj.parentNode.getElementsByTagName("span");
 for(var i=0;i<span.length;i++){span[i].className = "no";}
 span[n].className = "";
 var li = obj.parentNode.getElementsByTagName("li")
 li[n].className = "ok";
 for(var i=0;i<li.length;i++){
  if(i!=n){li[i].className = "";}
  li[i].onmouseout = function(){this.className = "ol";}
 }
}
function ShowUl(obj,n){
 var ul = obj.parentNode.getElementsByTagName("ul");
 var h1 = obj.parentNode.getElementsByTagName("h1");
 for(var i=0; i<h1.length;i++){
  h1[i].innerHTML = h1[i].innerHTML.replace("-","+");
  h1[i].className = "";
 }
 if(ul[n].className == "no"){
  ul[n].className = "";
  obj.className = "ok";
  obj.innerHTML = obj.innerHTML.replace("+","-");
 }else{
  ul[n].className = "no";
  return;
 }
 for(var i=0; i<ul.length;i++){if(i!=n){ ul[i].className = "no";}}
}
//-->
</script>
</head>
<body>
<div >http://www.webdm.cn/webcode/eae5b017-4f40-47d7-95b2-ea94fe1ee55d.html

 

 

相关文章: