当前位置:首页 > 学习手记 > 正文内容

一款CSS垂直下拉导航栏CSS

心砚17年前 (2009-04-22)学习手记2079

演示: 

 

首先是CSS样式:

<style type="text/css">
<!--
body {
font-family: arial, "宋体", serif;
font-size:12px;
}
#nav *{margin:0;padding:0;border:0;}
#nav {
 line-height: 34px;
 list-style-type: none;
 background-color: #999999;
}
#nav a {
display: block; width: 100px; 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: 100px; background:#CCC;
}
#nav li a:hover{
background:#999;
}
#nav li ul {
line-height: 27px; list-style-type: none;text-align:left;
left: -999em; width: 100px; position: absolute;
}
#nav li ul li{
float: left; width: 100px;
background: #F6F6F6;
}
#nav li ul a{ wedisplay: block; width: 76px;text-align:left;padding-left:24px;
}
#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 {
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>

最后是调用:

<ul id="nav">
<li><a href="index.asp">网站首页</a></li>
<li><A href="cxabout.asp" target=_self>关于诚迅</A>
 <ul>
  <li><A href="cxabout.asp" target=_self>关于诚迅</A></li>
  <li><a href="culture.asp">企业文化</a></li>
  <li><a href="cxjob.asp">人才招聘</a></li>
 </ul>
</li>
<li><a href="cxnews.asp">新闻中心</a>
 <ul>
  <li><a href="cxgsnews.asp">诚迅新闻</a></li>
  <li><a href="cxhynews.asp">行业新闻</a></li>
  <li><a href="cxnews.asp">全部新闻</a></li> 
 </ul>
</li>
<li><A href="cxfuwu.asp" target=_self>诚迅服务</A>
 <ul>
  <li><A href="cxfuwu.asp" target=_self>诚迅服务</A></li>
  <li><A href="cxhuanjing.asp" target=_self>仓储环境</A></li>
 </ul>
</li>
<li><A href="cxfanwei.asp" target=_self>业务范围</A>
 <ul>
  <li><A href="cxfanwei.asp" target=_self>业务范围</A></li>
  <li><a href="cxliucheng.asp">业务流程</a></li>
  <li><a href="cxanli.asp">运输案例</a></li>
  <li><a href="cxinfo.asp">信息查询</a></li>
 </ul>
</li>
<li><a href="cxbook.asp">客户留言</a>
</li>
<li><a href="cxlianxi.asp">联系我们</a>
</li>
</ul>

 

 

扫描二维码推送至手机访问。

版权声明:本文由皋城心砚发布,如需转载请注明出处。

本文链接:https://www.heyh.cn/92.html

相关文章