Reputation: 6062
I have this drop down menu, that when it's hovered some of the content is going behind another div. It looks like this:
The css for the menu is like this:
.nav-m {
height: 50px;
width: 60px;
display: block;
position: absolute;
z-index: 9999;
overflow-y: hidden;
text-align: center;
position: absolute;
}
.nav-m:hover {
width: 140px;
height: 210px;
}
.nav-m a {
display: none;
text-indent: -9999px;
position: relative;
height: 20px;
padding: 13px 0;
color: #fff !important;
}
nav a:first-child:hover {
text-indent: -9999px;
}
.nav-m:hover>a {
display: block;
}
.nav-m:hover>a:first-child:after {
color: #6daeaf;
background: #505664;
}
.nav-m a:first-child {
display: block;
text-align: center;
margin-bottom: 16px;
cursor: default;
}
.nav-m a:after {
position: absolute;
top: 0;
padding: 12px 0;
width: 60px;
color: #fff;
font-family: 'icons';
font-size: 24px;
display: block;
text-indent: 0;
background: #6daeaf;
}
nav a:hover {
text-indent: 0px;
text-align: left;
margin-left: 70px;
}
.nav-m a:hover:after {
color: #999;
background: #fff;
text-align: center;
margin-left: -70px;
}
.nav-m a:first-child:before {
position: absolute;
text-indent: 0;
top: 55px;
left: 23px;
content: "";
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #6daeaf;
}
.nav-m a:first-child:hover:before {
margin-left: -70px;
}
.nav-m a:first-child:after {
left: 0;
content: "m";
background: #656d7e;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.nav-m a:nth-child(2):after {
content: "p";
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.nav-m a:nth-child(3):after {
content: "s";
}
.nav-m a:last-child:after {
content: "e";
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-radius-bottomleft: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
Below the menu div is .container, .row and then a div with class='span12' (I'm using bootstrap)
The HTML looks like this:
<div id="topbg">
<div class="span9">span9 content here</div>
<div class="span3 avatar-holder" >
<nav class="nav-m" onmouseover="">
<a href="#" title="Menu">Menu</a>
<a href="#" title="Account">Account</a>
<a href="#" title="Settings">Settings</a>
<a href="#" title="Email">Email</a>
<a href="#" title="Email">Email</a>
<a href="#" title="Email">Email</a>
<a href="#" title="Email">Email</a>
<a href="#" title="Email">Email</a>
<a href="#" title="Email">Email</a>
<a href="#" title="Email">Email</a>
</nav>
</div>
</div>
</div><!--end row-->
</div><!--end topbg-->
<div class='container' style='margin-top:20px;'>
<div class='row'>
<div class='span12' style='margin:0;'>
span 12 content
</div><!--end span12-->
</div><!--end row-->
So, I've tried setting the z-index to -1 on the following divs: .row, .container, .span12 with no luck. I've also tried settings the overflow to visible on every possible div. I can't find the problem here.
Can anyone help me out?
Upvotes: 0
Views: 249
Reputation: 10168
The div is not overlaping the menu. It is the menu items which are not visible.
You have text-indent: -9999px
on .nav-m a
menu items and you reverted that for first three items thanks to following CSS
.nav-m a:nth-child(3):after {
content: "s";
}
.nav-m a:nth-child(2):after {
content: "p";
}
.nav-m a:first-child:after {
content: "m";
}
Now look at general styles for all your menu items:
.nav-m a:after {
position: absolute;
top: 0;
padding: 12px 0;
width: 60px;
color: #FFF;
font-family: 'icons';
font-size: 24px;
display: block;
text-indent: 0;
background: #6DAEAF;
}
It misses the content
property which is crucial here. Without it the pseudo-element :after
won't be rendered at all.
To prove that, I prepared a JSFIDDLE with your code (no modifications). It doesn't contain this overlaping div at all but the problem is still present.
If you want to stay with this approach I'd suggest a minor change which will spare you lots of CSS.
To every menu item anchor add an attribute data-shortcut
which will hold the first letter of the menu item
<a href="#" title"Settings" data-shortcut="s">Settings</a>
and so on... Now you can access this attribute in CSS content
property
content: attr(data-shortcut);
Thanks to that you don't need to define CSS for every menu item with different first letter.
Upvotes: 1
Reputation: 2631
Z-index only effects elements that have a position set to them. Make sure you have position:relative
or position:absolute
set to both the dropdown and the div covering it.
Upvotes: 0
Reputation: 1095
Try to give z-index
value more than div on which it is overlapping.
Example : If div1
contains z-index 10
, then give greater z-index to <nav>
which is hiding behind `div1'.
Upvotes: 0