您的位置:首页 > Web前端 > CSS

经典的蓝色JS+CSS下拉菜单

2011-10-13 15:51 453 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!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 runat="server">
<title>无标题页</title>
<style type="text/css">
*{margin:0;padding:0;border:0;}
#div_center { width:790px; height:23px; background:#003399; margin-left: auto;margin-right:auto;}
#nav { line-height: 20px; list-style-type: none; margin-top:5px;}
#nav a { display: block; width: 77px; text-align:center; font-size:12px;}
#nav a:link { color:#FFF; text-decoration:none;margin:0;}
#nav a:visited {color:#FFF;text-decoration:none;margin:0;}
#nav a:hover {color:#C00;text-decoration:none;}
#nav li {float: left;}
#nav li a:hover{background:#FFFFFF;}
#nav li ul {line-height: 24px; background:#FFF; list-style-type: none;text-align:left;left: -999em; width:132px; position: absolute;border-width: 1px;border-top-style: none;border-right-style: solid;border-bottom-style: solid;border-left-style: solid;border-color: #003399; padding:1px;}
#nav li ul a{display:block; width: 130px;text-align:left;padding-left:2px;}
#nav li ul a:link {color:#0d5097; text-decoration:none;}
#nav li ul a:visited {color:#0d5097;text-decoration:none;}
#nav li ul a:hover {color:#FFF;text-decoration:none;font-weight:normal;background:#003399;}
#nav li:hover ul {left: auto;}
#nav li.sfhover ul {left: auto;}
#content {clear: left;}
</style>
<script 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? " ": "") + "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>
<form id="form1" runat="server">
<div id=div_center>
<UL id=nav>
<LI style="MARGIN-LEFT: 10px"><A href="#">主站索引</A></LI>
<LI><A href="#">新闻中心</A>
<UL>
<LI><A href="#">·新闻中心1</A></LI>
<LI><A href="#">·新闻中心3</A></LI></UL></LI>
<LI><A href="#">企业简介</A>
<UL>
<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></UL></LI>
<LI><A href="#">国际新闻</A>
<UL>
<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></UL></LI>
<LI><A href="#">下载中心</A>
<UL>
<LI><A href="#">·常用软件</A></LI>
<LI><A href="#">·文档下载</A></LI>
<LI><A href="#">社区论坛</A></LI></UL>
</div>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: