我有一个下拉菜单,如下所示:
<ul id="secondary-nav" class="menu">
<li><a href="#">boeketten</a>
<ul>
<li>7 rododendrons</li>
<li>7 rozen</li>
</ul>
</li>
<span>∼</span>
<li><a href="#">bloemstukken</a></li>
<span>∼</span>
<li><a href="#">planten</a></li>
<span>∼</span>
<li><a href="#">bruidsruikers</a></li>
<span>∼</span>
<li><a href="#">kerkdecoratie</a></li>
<span>∼</span>
<li><a href="#">evenementen</a></li>
<span>∼</span>
<li><a href="#">rouwwerk</a></li>
<span>∼</span>
<li><a href="#">rocabo potten</a></li>
</ul>
这是我用来设置它的样式:
ul#secondary-nav {
z-index: 9999;
}
ul#secondary-nav li, ul#secondary-nav > span {
display:block;
position:relative;
float: left;
}
ul#secondary-nav li ul {
display: none;
text-align:left;
padding-left: 0px;
background-color: red;
}
ul#secondary-nav li ul li {
float: none;
display: block;
}
ul#secondary-nav li:hover ul {
display: block;
position: absolute;
}
但它属于其他内容,如下:
![enter image description here][1]
我怎样才能让它在它之上?
答案 0 :(得分:5)
您为主z-index
定义了ul
,但它似乎处于静态位置(因此z-index
无效):尝试使用
ul#secondary-nav {
z-index: 9999;
position: relative;
}