需要更改下拉css菜单以便放弃

时间:2013-01-04 01:03:28

标签: css drop-down-menu menu

我需要将此纯css下拉菜单修改为dropup。看到一个类似的帖子,但似乎无法修改我的。这是用于下拉列表的css代码,它按预期工作。我尝试在bottom: 100%中使用ul.drop li.hover, ul.drop li:hover {,但这不起作用。任何建议。

HTML     

<body>

<ul id="nav" class="drop">
  <li><a href="#">Home</a></li>
  <li>Portfolio
    <ul>
      <li><a href="#">Horses</a>
        <ul>
          <li><a href="#">Horses 1</a>
          <li><a href="#">Horses 2</a>
          <li><a href="#">Horses 3</a>
        </ul>
      </li>
      <li><a href="#">Dogs</a></li>
      <li><a href="#">People</a></li>
      <li><a href="#">Stills</a></li>
    </ul>
  </li>
  <li><a href="#">Order</a></li>
  <li><a href="#">Contact Me</a>
     </li>
    </ul>
  </li>
</ul>

CSS

ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
list-style: none;
}

ul li {
display: block;
position: relative;
float: left;
width: 130px;
text-align: center;
}
li ul {
display: none;
}

ul li a {
    display: block;
    text-decoration: none;
    color: #ffffff;
    border-top: 0px solid #ffffff;
    padding: 0px 0px 0px 0px;
    background: transparent;
#    margin-left: 1px;
    white-space: nowrap;
}
ul li a:hover {
background: transparent;
}
li:hover ul {
    display: block;
    position: absolute;
}
li:hover li {
    float: none;
    font-size: 11px;
    width: 160px;
    text-align: left;
}
li:hover a { background: transparent; }
li:hover li a:hover {
    background: #3ba110;
}

ul.drop a {
display:block; color: #fff; font-family: Verdana; font-size: 14px; text-decoration:    none;
}


ul.drop, ul.drop li, ul.drop ul {
list-style: none; margin: 0; padding: 0; border: 1px solid #fff; background: #1302CB; color: #fff;
}
ul.drop {
position: relative; z-index: 597; float: left;
}
ul.drop li {
float: left; line-height: 1.3em; vertical-align: middle; zoom: 1; padding: 5px 10px;
}
ul.drop li.hover, ul.drop li:hover {
position: relative; z-index: 599; cursor: default; background: #3ba110;
}

ul.drop ul {
visibility: hidden; position: absolute; bottom: 100%; left: 0; z-index: 598; width: 160px; background: #cccccc; border: 1px solid #fff;
}

ul.drop ul li {
float: none;
}
ul.drop ul ul {
top: -2px; left: 100%;
}

ul.drop li:hover > ul {
visibility: visible
}

1 个答案:

答案 0 :(得分:0)

我没有使用你的CSS因为我不确定没有HTML会发生什么。无论如何,我创建了一个我认为你想要完成的基本演示。

http://jsfiddle.net/krishollenbeck/JgWEL/45/

<强> HTML

<div class="page">
<ul>
    <li class="navlink">
        <a href="">MENU ITEM:</a>
        <ul class="dropmenu">
            <li><a href="">Link One</a></li>
            <li><a href="">Link Two</a></li>
            <li><a href="">Link Three</a></li>
        </ul>   
    </li>    
</ul>  
</div>

<强> CSS

.page {
    width:200px;
    height:100px;
    position:fixed;
    top:50%;
    bottom:50%;
}    
.dropmenu {
    display:none;
    border:1px solid #CCC;
    background-color:#eee;
    width:150px;
    padding:5px;
    position:absolute;
    top:-70px;
}
.navlink {
    background-color:#000;
    padding:5px;
}
.navlink > a {color:#FFF;}
.navlink:hover > .dropmenu {display:block;}
​