带有水平子菜单的CSS Jquery垂直导航菜单

时间:2011-07-21 11:43:14

标签: javascript jquery css navigation

2 个答案:

答案 0 :(得分:0)

试试这个:

#mainmenu>li {
height: 40px;
margin: 5px;
position: relative;
clear:both

}

并浮动到链接:

#mainmenu a {

float:left;

background: none repeat scroll 0 0 #333;
color: #fff;
display: block;
font-family: Folio;
font-size: 30px;
padding: 2px 15px;
text-decoration: none;
text-transform: uppercase;
width: 160px;
height: 40px;
overflow: hidden;
}

答案 1 :(得分:0)

这是你可能想要的:

css:

#mainmenu {
  position: fixed;
  left: 20px;
  top: 50%;
  z-index: 999999;
  margin-top:-200px;
}

  #mainmenu li {
    height: 40px;
    margin: 5px;
    position: relative;
  }

  #mainmenu a {
    background: none repeat scroll 0 0 #333;
    color: #fff;
    display: block;
    font-family: Folio;
    font-size: 30px;
    padding: 2px 15px;
    text-decoration: none;
    text-transform: uppercase;
    width: 160px;
    height: 40px;
    /*background: url(Images/dotnav.png) 0 100% no-repeat;*/
 /*text-indent: -10000px;*/
    overflow: hidden;
  }


  #mainmenu a:hover,
  #mainmenu li.active a {
    background-position: 0 0;

  }
.submenu
{
    list-style-type: none; 
    position:relative;
    float:left;

}
.submenu li
{
    display: inline; 
    float:left; 
    position:relative;

}
#mainmenu .submenu li{
    margin:0px; 
}

和html

<div>
        <nav>
        <ul id="mainmenu">
                <li><a href="chi_siamo">Chi siamo</a></li>
                <li><a href="servizi" style="float:left">Servizi</a>
                <ul class="submenu">
                    <li>
                        <a href="speciale">speciale</a>
                    </li>
                    <li>
                        <a href="#">privati</a>
                    </li>
                    <li>
                        <a href="">aziende</a>
                    </li>
                    <li>
                        <a href="">cerimonie</a>
                    </li>
                    <li>
                        <a href="">consulenza</a>
                    </li>
                </ul>
                </li>

                <li style="clear:both;"><a href="location">Location</a></li>
                <li><a href="contatti">contatti</a></li>
                <li class="last"><a href="partner">partner</a></li>
                </ul>
                </nav>
    </div>

在html中我添加了“servizi”浮动左侧,在css中我添加了:

#mainmenu .submenu li{
        margin:0px; 
    }

所以他们现在处于同一水平。