下拉导航 - 两层菜单(CSS / HTML)

时间:2011-07-18 22:06:44

标签: html css menu drop-down-menu

我一直致力于 弄清楚如何制作双下拉菜单

我正在使用的实时页面:http://www.glustik.com/dustreeproductions/

娱乐”按钮将是唯一一个具有下拉功能的按钮。 我已经设置了父选择,但每个选中时都会有一小部分乐队。

示例:“舞蹈”将有大约7个乐队(乐队#1 - 乐队#7) 辅助下拉列表应显示在父下拉菜单的右侧。

非常感谢任何帮助。我一直在努力解决这个问题。

我的Relavant HTML(nav)标记:

    <div id="main-nav">
        <div id="nav">
            <ul>
                <li id="company"><a title="Company" href="http://www.glustik.com/dustreeproductions/company.php"></a></li>
                <li id="entertainment"><a title="Entertainment" href="http://www.glustik.com/dustreeproductions/entertainment.php"></a>
                    <ul id="sub">
                    <li id="dance"> <a href="http://www.jasontanzer.com/guitarist-original-music.asp">Dance</a></li>
                    <li id="classicRock"><a href="http://www.jasontanzer.com/guitarist-shows-covers.asp">Classic Rock | Top 40 | Rock</a></li>
                    <li id="country"><a href="http://www.jasontanzer.com/commercial-tv-film-jingles.asp">Country</a></li>
                    <li id="rockabilly"><a href="http://www.jasontanzer.com/composer.asp">Rockabilly | Reggae | Bluegrass | Other</a></li> 
. . . . .  and so on.

我的CSS(nav)标记:

#nav #company a  {
    background:url(../images/navigation/nav-company.png) no-repeat;
    display:block;
    text-decoration:none;
    width:103px;
    margin:20px 27px 0 20px;
    height:20px;}
    #nav #company:hover > a {
    background-position:0 -20px;}
    #nav #company a:active {
    background-position:0 -40px;}
    body#body_company #company a {
    background-position:0 -40px;}

#nav #entertainment a  {
    background:url(../images/navigation/nav-entertainment.png) no-repeat;
    display:block;
    text-decoration:none;
    width:168px;
    margin:20px 27px 0 0;
    height:20px;}
    #nav #entertainment:hover > a {
    background-position:0 -20px;}
    #nav #entertainment a:active {
    background-position:0 -40px;}
    body#body_entertainment #entertainment a {
    background-position:0 -40px;}
. . . . . and so on.

1 个答案:

答案 0 :(得分:2)

由于您的CSS已经包含child combinator选择器,我假设您不关心不支持它的浏览器(如IE6)。

只有CSS can be done。我将文本添加到<a>元素以用于显示目的,并将 Band#1 - Band#7 添加到 Dance Band#1 到下一个项目,只是为了显示与音乐类型顶部的对齐。

希望这会有所帮助: - )