用户登陆:
设为首页 | 加入收藏 | 全站地图
您现在的位置: 星星雨设计站 >> 网络学院 >> 网页设计 >> CSS导航实例 >> 教程正文
The six level drop-down menu with overlap and overrun - centered
作者:佚名    教程来源:本站原创    点击数:    更新时间:2007-12-24

Information

This one is for all of you who wanted to know how to center the previous menu. All that is required is a small change of style for non-IE browsers and an extra sylesheet for IE.

This also works in Internet Explorer IE5.5, IE6, IE7, Opera and now Safari, Netscape 8 and Mozilla.

NOTE:Firefox has a problem with this and does not always produce the required result. I am seeking ways around this.

 

=====================================

#nav {position:relative; z-index:100; margin:50px 0 150px 0;}
#nav h2 {font-family: "trebuchet ms", arial, sans-serif; font-weight:normal; color:#090;}
#nav h3 {font-family: "trebuchet ms", arial, sans-serif; font-weight:normal;}


/* Get rid of the margin, padding and bullets in the unordered lists */
#pmenu {padding:0; margin:0 auto; list-style-type: none; display:table;}
#pmenu ul {padding:0; margin:0; list-style-type: none; display:block;}

/* Hide the sub levels */
#pmenu li ul {display:none;}

/* Set up the link size, color and borders */
#pmenu li a, #pmenu li a:visited {display:block;  width:120px; font-size:11px; color:#fff; height:25px; line-height:24px; text-decoration:none; text-indent:5px; border:1px solid #000; border-width:1px 0 1px 1px; text-align:left;}

/* Set up the sub level borders */
#pmenu li ul li a, #pmenu li ul li a:visited {border-width:0 1px 1px 1px;}
#pmenu li a.enclose, #pmenu li a.enclose:visited {border-width:1px;}

/* Set up the list items */
#pmenu li {float:left; background:#7484ad;}
#pmenu li.tc {display:table-cell;}

/* For Non-IE browsers and IE7 */
#pmenu li:hover {position:relative;}
/* Make the hovered list color persist */
#pmenu li:hover > a {background:#dfd7ca; color:#c00;}
/* For Non-IE and IE7 make the sublevels visible on list hover. This is all it needs */
#pmenu li:hover > ul {display:block; position:absolute; top:-11px; left:80px; padding:10px 30px 30px 30px; background:transparent url(transparent.gif); width:120px;}
/* Position the first sub level beneath the top level liinks */
#pmenu > li:hover > ul {left:-30px; top:16px;}

/* get rid of the table */
#pmenu table {position:absolute; border-collapse:collapse; top:0; left:0; z-index:100; font-size:1em;}

/* For IE5.5 and IE6 give the hovered links a position relative and a change of background and foreground color. This is needed to trigger IE to show the sub levels */
* html #pmenu li a:hover {position:relative; background:#dfd7ca; color:#c00;}

/* For accessibility of the top level menu when tabbing */
#pmenu li a:active, #pmenu li a:focus {background:#dfd7ca; color:#c00;}

/* Set up the pointers for the sub level indication */
#pmenu li.fly {background:#7484ad url(/menus/fly.gif) no-repeat right center;}
#pmenu li.drop {background:#7484ad url(/menus/drop.gif) no-repeat right center;}


/* This lot is for IE5.5 and IE6 ONLY and is necessary to make the sublevels appear */

/* change the drop down levels from display:none; to visibility:hidden; */
* html #pmenu li ul {visibility:hidden; display:block; position:absolute; top:-11px; left:80px; padding:10px 30px 30px 30px; background:transparent url(transparent.gif);}

/* keep the third level+ hidden when you hover on first level link */
#pmenu li a:hover ul ul{
visibility:hidden;
}
/* keep the fourth level+ hidden when you hover on second level link */
#pmenu li a:hover ul a:hover ul ul{
visibility:hidden;
}
/* keep the fifth level hidden when you hover on third level link */
#pmenu li a:hover ul a:hover ul a:hover ul ul{
visibility:hidden;
}
/* keep the sixth level hidden when you hover on fourth level link */
#pmenu li a:hover ul a:hover ul a:hover ul a:hover ul ul {
visibility:hidden;
}

/* make the second level visible when hover on first level link and position it */
#pmenu li a:hover ul {
visibility:visible; left:-30px; top:14px; lef\t:-31px; to\p:15px;
}

/* make the third level visible when you hover over second level link and position it and all further levels */
#pmenu li a:hover ul a:hover ul{
visibility:visible; top:-11px; left:80px;
}
/* make the fourth level visible when you hover over third level link */
#pmenu li a:hover ul a:hover ul a:hover ul {
visibility:visible;
}
/* make the fifth level visible when you hover over fourth level link */
#pmenu li a:hover ul a:hover ul a:hover ul a:hover ul {
visibility:visible;
}
/* make the sixth level visible when you hover over fifth level link */
#pmenu li a:hover ul a:hover ul a:hover ul a:hover ul a:hover ul {
visibility:visible;
}
/* If you can see the pattern in the above IE5.5 and IE6 style then you can add as many sub levels as you like */
</style>

<!--[if IE]>
<style type="text/css">
#nav ul {display:inline-block;}
#nav ul {display:inline;}
#nav ul li {float:left;}
#nav {text-align:center;}

发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口教程录入:冰河    责任编辑:冰河 
  • 上一篇教程:

  • 下一篇教程: 没有了
  • 精彩视频
    最新热门
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明