CSS水平子菜单

时间:2011-11-28 10:40:03

标签: css submenu

基本上我有一个并排的水平菜单,你可以在这里看到:http://www.supplements-today.co.uk/walnutgarth3/availability.php

我想要做的是让'onhover'有一个子菜单可以降低某些选项,例如'pictures'。我可以在这里看到我的尝试:http://www.supplements-today.co.uk/walnutgarth3/

现在我已经让下拉部分工作了,但是如你所见,它会破坏我菜单其余部分的风格。对我来说问题是'

任何人都知道我的问题在这里?你可以在pagesource中看到我的菜单代码,但到目前为止,我的css是:

#tier1 div{ display:none; }

#tier1{
position: relative;
left: 70px;
height: 20px;

}

#tier2{
position: relative;
display: block;


}  

我知道那是空的,但iv用各种各样的方式玩弄,似乎无法让它发挥作用。任何帮助非常感谢:)

2 个答案:

答案 0 :(得分:0)

尝试使用一些JQuery菜单插件。 JQuery被广泛使用,并且有很多通过互联网浏览菜单的例子。 其中一个例子可以找到here.

答案 1 :(得分:0)

试试这个html代码可能你想要这样的格式:

        <html>
        <head>
        <style>
        #pcm{display:none;}
        ul.cssMenu ul{display:none}
        ul.cssMenu li:hover>ul{display:block}
        ul.cssMenu ul{position: absolute;left:-1px;top:98%;}
        ul.cssMenu ul ul{position: absolute;left:98%;top:-2px;}
        ul.cssMenu,ul.cssMenu ul {
            margin:0px;
            list-style:none;
            padding:0px 1px 1px 0px;
            background-color:#A5A5A5;
            background-repeat:repeat;
            border-color:#A6A6A6;
            border-width:0px;
            border-style:solid;
        }
        ul.cssMenu table {border-collapse:collapse}ul.cssMenu {
            display:block;
            zoom:1;
            float: left;
        }
        ul.cssMenu ul{
            width:150px;
        }
        ul.cssMenu li{
            display:block;
            margin:1px 0px 0px 1px;
            font-size:0px;
        }
        ul.cssMenu a:active, ul.cssMenu a:focus {
        outline-style:none;
        }
        ul.cssMenu a, ul.cssMenu li.dis a:hover, ul.cssMenu li.sep a:hover {
            display:block;
            vertical-align:middle;
            background-color:#FFFFFF;
            border-width:0px;
            border-color:#787878;
            border-style:solid;
            text-align:left;
            text-decoration:none;
            padding:5px;
            padding-left: 8px;
            padding-right: 8px;
            width:130px;
            font:normal 11px Arial;
            color: #000000;
            text-decoration:none;
            cursor:pointer;
        }
        ul.cssMenu span{
            overflow:hidden;
        }
        ul.cssMenu li {
            float:left;
        }
        ul.cssMenu ul li {
            float:none;
        }
        ul.cssMenu ul a {
            text-align:left;
            white-space:nowrap;
        }
        ul.cssMenu li.sep{
            text-align:left;
            padding:0px;
            line-height:0;
            height:100%;
        }
        ul.cssMenu li.sep span{
            float:none; padding-right:0;
            height:100%;
            background-color:#424242;   background-image:none;}
        ul.cssMenu ul li.sep span{
            width:100%;
            height:3;
        }
        ul.cssMenu li:hover{
            position:relative;
        }
        ul.cssMenu li:hover>a{
            background-color:#5A5A5A;
            border-color:#4C99AB;
            border-style:solid;
            font:normal 11px Arial;
            color: #FFFFFF;
            text-decoration:none;
        }
        ul.cssMenu li a:hover{
            position:relative;
            background-color:#5A5A5A;
            border-color:#4C99AB;
            border-style:solid;
            font:normal 11px Arial;
            color: #FFFFFF;
            text-decoration:none;
        }
        ul.cssMenu li.dis a {
            color: #AAAAAA !important;
        }
        ul.cssMenu img {border: none;float:left;_float:none;margin-right:5px;width:16px;
        height:16px;
        }
        ul.cssMenu ul img {width:16px;
        height:16px;
        }
        ul.cssMenu img.over{display:none}
        ul.cssMenu li.dis a:hover img.over{display:none !important}
        ul.cssMenu li.dis a:hover img.def {display:inline !important}
        ul.cssMenu li:hover > a img.def  {display:none}
        ul.cssMenu li:hover > a img.over {display:inline}
        ul.cssMenu a:hover img.over,ul.cssMenu a:hover ul img.def,ul.cssMenu a:hover a:hover ul img.def,ul.cssMenu a:hover a:hover a:hover ul img.def,ul.cssMenu a:hover a:hover img.over,ul.cssMenu a:hover a:hover a:hover img.over,ul.cssMenu a:hover a:hover a:hover a:hover img.over{display:inline}
        ul.cssMenu a:hover img.def,ul.cssMenu a:hover ul img.over,ul.cssMenu a:hover a:hover ul img.over,ul.cssMenu a:hover a:hover a:hover ul img.over,ul.cssMenu a:hover a:hover img.def,ul.cssMenu a:hover a:hover a:hover img.def,ul.cssMenu a:hover a:hover a:hover a:hover img.def{display:none}
        ul.cssMenu a:hover ul,ul.cssMenu a:hover a:hover ul,ul.cssMenu a:hover a:hover a:hover ul{display:block}
        ul.cssMenu a:hover ul ul,ul.cssMenu a:hover a:hover ul ul{display:none}
        ul.cssMenu span{
            display:block;
            background-image:url(http://purecssmenu.com/ssc-data/templates/clear-2/images/arrv_blue_2.gif);
            background-position:right center;
            background-repeat: no-repeat;
           padding-right:8px;}
        ul.cssMenu li:hover>a>span{ background-image:url(http://purecssmenu.com/ssc-data/templates/clear-2/images/arrv_white_2.gif);
        }
        ul.cssMenu a:hover span{    _background-image:url(http://purecssmenu.com/ssc-data/templates/clear-2/images/arrv_white_2.gif)}
        ul.cssMenu ul span,ul.cssMenu a:hover table span{background-image:url(http://purecssmenu.com/ssc-data/templates/clear-2/images/arr_blue_2.gif)}
        ul.cssMenu ul li:hover > a span{    background-image:url(http://purecssmenu.com/ssc-data/templates/clear-2/images/arr_white_2.gif);}
        ul.cssMenu table a:hover span,ul.cssMenu table a:hover a:hover span,ul.cssMenu table a:hover a:hover a:hover span{background-image:url(http://purecssmenu.com/ssc-data/templates/clear-2/images/arr_white_2.gif)}
        ul.cssMenu table a:hover table span,ul.cssMenu table a:hover a:hover table span{background-image:url(http://purecssmenu.com/ssc-data/templates/clear-2/images/arr_blue_2.gif)}
        ul.cssMenu li a.cssMenui0{
        font:n;
        }
        ul.cssMenu li a.cssMenui0:hover{
        font:o;
        }
        </style>
        </head>
        <body>
        <ul class="cssMenu cssMenum">
            <li class=" cssMenui0"><a class="  cssMenui0" href="#"><span>Data Transfer</span></a>
            <ul class=" cssMenum">
                <li class=" cssMenui"><a class="  cssMenui" href="#">Import From SPP Offline</a></li>
                <li class=" cssMenui"><a class="  cssMenui" href="#">Export to SPP Offline</a></li>
            </ul>
            </li>
            <li class=" cssMenui0"><a class="  cssMenui0" href="#"><span>Settings</span><!--[if gt IE 6]--></a>
            <ul class=" cssMenum">
                <li class=" cssMenui"><a class="  cssMenui" href="#">Leave Report Settings</a></li>
                <li class=" cssMenui"><a class="  cssMenui" href="#">Mail Server Settings</a></li>
                <ul class=" cssMenum">
                    <li class=" cssMenui"><a class="  cssMenui" href="#"><span>Windows OS</span></a>
                    <ul class=" cssMenum">
                        <li class=" cssMenui"><a class="  cssMenui" href="#">Internet Explorer</a></li>
                        <li class=" cssMenui"><a class="  cssMenui" href="#">Netscape Navigator</a></li>
                    </ul>
                    </li>
                    <li class=" cssMenui"><a class="  cssMenui" href="#">MAC OS</a></li>
                    <li class=" cssMenui"><a class="  cssMenui" href="#">Unix/Linux OS</a></li>
                </ul>
                </li>
                <li class=" cssMenui"><a class="  cssMenui" href="#">About Company</a></li>
                <li class=" cssMenui"><a class="  cssMenui" href="#">Flash News</a></li>
            </ul>
            </li>
            <li class=" cssMenui0"><a class="  cssMenui0" href="#"><span>Admin References</span></a>
            <ul class=" cssMenum">
                <li class=" cssMenui"><a class="  cssMenui" href="#">Change Password</a></li>
                <li class=" cssMenui"><a class="  cssMenui" href="#">Login History</a></li>
            </ul>
            </li>
            <li class=" cssMenui0"><a class="  cssMenui0" href="#"><span>User Details</span></a>
            <ul class=" cssMenum">
                <li class=" cssMenui"><a class="  cssMenui" href="#">User Master</a></li>
                <li class=" cssMenui"><a class="  cssMenui" href="#">Assign Employee to Sanction</a></li>
            </ul>
            </li>
            <li class=" cssMenui0"><a class="  cssMenui0" href="#"><span>Reports</span></a>
            <ul class=" cssMenum">
                <li class=" cssMenui"><a class="  cssMenui" href="#">Assigned Employees</a></li>
                <li class=" cssMenui"><a class="  cssMenui" href="#">Unassigned Employees</a></li>
            </ul>
            </li>
        </ul>
        </body>
        </html>