内容CSS下的水平链接下降

时间:2013-01-28 18:37:40

标签: css drop-down-menu hyperlink overlapping

我正在努力创建我的第一个wordpress主题,而我在横向下拉时遇到问题。悬停时,下拉列表会显示在内容下方。

http://pennyjarrdesigns.com/assets/problem1.jpg(截图)

我尝试过使用z-index并调整相对和绝对定位,似乎没什么用。在导航周围为主div添加绝对值会产生以下结果:

http://pennyjarrdesigns.com/assets/problem2.jpg(截图)

下拉列表现在可见,但它会破坏布局。

这是html / php:

<div class="container">
<div class="row">
    <div class="twelvecol last" id="nav">
        <?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'menu_class' => 'nav', 'theme_location' => 'primary-menu' ) ); ?>

    </div>

</div>

CSS:

#nav{background: #4b4261;
margin-bottom: 2%;
color: #f4e1c8;
 }

.nav{
width:100%;
background: #4b4261;
display:block;
float:left;
position:relative;
}

.nav ul{
list-style:none;
}

.nav li{
display:inline-block;
position:relative;
}
.nav a{
display:block;
text-decoration:none;
color:#f4e1c8;
padding:0 15px 10px 0;
font-size: 1.2em; 
font-weight:bold;
}

.nav ul ul{
display:none;
position: absolute;
left:0;
top: 100%;
float:left;
z-index:99999;
background: #c1c5cc;
}

.nav ul ul ul{
top: 30%;
left:100%;
background: #dfe1e8;
}

.nav ul ul a{
height:auto;
line-height:1em;
padding:10px;
width:130px;
}

.nav li:hover > a,.nav ul ul:hover > a{
color:#fff;

}

.nav ul li:hover > ul{
display:block;
 }

grid css:

.container {
padding-left: 20px;
padding-right: 20px;
}

.row {
width: 100%;
max-width: 1140px;
min-width: 755px;
margin: 0 auto;
overflow: hidden;


}

.onecol, .twocol, .threecol, .fourcol, .fivecol, .sixcol, .sevencol, .eightcol, .ninecol, .tencol, .elevencol {
margin-right: 3.8%;
float: left;
min-height: 1px;
}

我真的觉得我在这里忽略了一些简单的东西。有任何想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

您将.row的溢出隐藏起来,这意味着,不会显示任何超出该元素边框的内容。

此外,当您将子ul元素设置为position: absolute;z-index: 9999;时,其父元素设置为position:relative;,并且没有将z-index设置为高于content {1}}元素。因此,下拉z-index仅适用于其父“维度”(z-index级别),而不适用于页面的其余部分。这可能会导致问题,但我还没有测试过,只是在内存中工作。