经典导航标题下拉菜单示例(很爽的,呵呵)

发布时间:2007年09月17日      浏览次数:2278 次
<!--
使用的时候可将CSS代码与Javascript代码分别用一个文件保存起来,然后包含到该页即可使页面代码变得精简了,也可直接这样子使用。
CSS样式代码与Javascript代码基本不用修改,如果不是很懂的话最好不要修改,如果懂的人可根据自已的需要自行修改相关代码。
-->
<html>
<head>
<title>经典导航标题下拉菜单示例</title>
<style type="text/css">
<!--
body { FONT-SIZE: 12px; BACKGROUND: url(../images/bg.gif) #fff repeat-x left top; MARGIN: 0px; COLOR: #777; LINE-HEIGHT: 135%;}
A:link { COLOR: #5c7aa1; TEXT-DECORATION: none;}
A:visited { COLOR: #5c7aa1; TEXT-DECORATION: none;}
A:hover { COLOR: #f60; TEXT-DECORATION: none;}
A:active { COLOR: #bbb; TEXT-DECORATION: none;}
#main{ margin:10px; text-align:center;}
.menu { DISPLAY: block; FILTER: progid:DXImageTransform.Microsoft.DropShadow(color=white,offX=1,offY=1,positives=true); WIDTH: 98%; WHITE-SPACE: nowrap;text-decoration: none;}
.menu_css { BORDER-RIGHT: #6688aa 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #6688aa 1px solid; PADDING-LEFT: 5px; Z-INDEX: 3000; FILTER: alpha(opacity=70); VISIBILITY: hidden; PADDING-BOTTOM: 5px; BORDER-LEFT: #6688aa 1px solid; WIDTH: 80px; PADDING-TOP: 5px; BORDER-BOTTOM: #6688aa 1px solid; POSITION: absolute; BACKGROUND-COLOR: #ffffff; opacity: .7}
.menu_css A { PADDING-RIGHT: 0px; DISPLAY: block; PADDING-LEFT: 3px; PADDING-BOTTOM: 1px; WIDTH: 100%; PADDING-TOP: 3px;}
.menu_css A:link { TEXT-DECORATION: none;}
.menu_css A:visited { TEXT-DECORATION: none;}
.menu_css A:hover { TEXT-DECORATION: none;}
.menu_css A:active { TEXT-DECORATION: none;}
.menu_css A:hover { COLOR: white; BACKGROUND-COLOR: #404f5c;}
-->
</style>
<script language="javascript">
<!--
var disappeardelay=250
var enableanchorlink=0
var hidemenu_onclick=1
var ie5=document.all
var ns6=document.getElementById&&!document.all
function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}
function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}
function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined")
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}
function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}
function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}
function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}
function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
-->
</script>
</head>
<body>
<div id="main">
<span class="menu">
<a onmouseover="dropdownmenu(this, event, 'menu1')" href="#">菜单一</a> |
<a onmouseover="dropdownmenu(this, event, 'menu2')" href="#">菜单二</a> |
<a onmouseover="dropdownmenu(this, event, 'menu3')" href="#">菜单三</a> |
<a onmouseover="dropdownmenu(this, event, 'menu4')" href="#">菜单四</a> |
<a onmouseover="dropdownmenu(this, event, 'menu5')" href="#">菜单五</a>
</span>
<div class="menu_css" id="menu1">
<a href="#">·子菜单一</a>
</div>
<div class="menu_css" id="menu2">
<a href="#">·子菜单一</a>
<a href="#">·子菜单二</a>
</div>
<div class="menu_css" id="menu3">
<a href="#">·子菜单一</a>
<a href="#">·子菜单二</a>
<a href="#">·子菜单三</a>
</div>
<div class="menu_css" id="menu4">
<a href="#">·子菜单一</a>
<a href="#">·子菜单二</a>
<a href="#">·子菜单三</a>
<a href="#">·子菜单四</a>
</div>
<div class="menu_css" id="menu5">
<a href="#">·子菜单一</a>
<a href="#">·子菜单二</a>
<a href="#">·子菜单三</a>
<a href="#">·子菜单四</a>
<a href="#">·子菜单五</a>
</div>
</div>
</body>
</html>
文章来源:桂林唯创网络
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!