当前位置:编程学习 > JS >>

兼容IE/火狐的蓝色CSS多级导航栏

看上去挺不错的CSS两级下拉菜单,兼容IE/火狐等多种浏览器,符合WEB标准,菜单天蓝色风格,鼠标移过菜单,会更换菜单背景,本菜单适合于大多数网站,因些总体还是不错的。
答案:<html>
<head>
<title>兼容IE/火狐的蓝色CSS多级导航栏</title>
<style>
body{font-size:12px; font-family:"宋体";margin:0;padding:0;}
#menu {height:29px!important;height:30px;line-height:29px;list-style-type: none;background:#B5DCF9;}
#menu a {display: block; width: 80px; text-align:center;}
#menu a:link {color:#000; text-decoration:none;}
#menu a:visited {color:#000;text-decoration:none;}
#menu a:hover {color:#FFF;text-decoration:none;font-weight:bold;}
#menu li {float: left; width: 80px;   border-right:1px solid #fff;}
#menu li a:hover{background:#6699ff;}
#menu li ul {line-height: 25px; list-style-type: none;text-align:left;left: -1860em; width: 180px; position: absolute;top:15px!important;top:29px;}
#menu li ul li{float: left; width: 130px;background: #6699ff;border-top:1px solid #fff}
#menu li ul a{display: block; width:120px!important;width: 130px;text-align:left;padding-left:10px;}
#menu li ul a:link {color:#fff; text-decoration:none;}
#menu li ul a:visited {color:#fff;text-decoration:none;}
#menu li ul a:hover {color:#000;text-decoration:none;font-weight:normal;background:#B5DCF9;}
#menu li:hover ul {left: auto;}
#menu li.sfhover ul {left: auto;}
#content {clear: left;}
</style>

<script type=text/javascript><!--//--><![CDATA[//><!--
function menuFix() {
var sfEls = document.getElementById("menu").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="menu">
<li><a href="#">回到首页</a></li>
<ul>
    <li>
     <a href="#">更新汇总</a>
     <a href="#">热门排行</a>
    </li>
   </ul>
<li><a href="/jscss">网页特效</a>
   <ul>
    <li>
     <a href="#">菜单导航</a>
     <a href="#">层和布局</a>
     <a href="#">表单按钮</a>
    </li>
   </ul>
</li>
<li><a href="#">代码资源</a>
   <ul>
    <li>
     <a href="#">ASP源码</a>
     <a href="#">PHP源码</a>
     <a href="#">JSP源码</a>
    </li>
   </ul>
</li>
<li><a href="/">电子书籍</a>
   <ul>
    <li>
     <a href="#">AJAX书籍</a>
     <a href="#">EXT类</a>
     <a href="#">JQUERY</a>
    </li>
   </ul>
</li>
<li><a href="#">其它杂项</a>
   <ul>
    <li>
     <a href="#">网站留言</a>
     <a href="#">广告业务</a>
    </li>
   </ul>
</li>
</div>
</body>
</html>

上一个:四个角都为弧形的纯CSS圆角导航栏
下一个:CSS+XHTML极酷导航菜单

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,