phphunger phphunger - 4 months ago 9
Javascript Question

Jquery dropdown hiding behind the wrapper div

As i am working on jquery dropdown list for my games site. I got struck at one issue. My dropdown goes behind the wrapper div when i mouse over it on the dropdown. Can anyone tell me what's wron with my code. See my sample code and image.
enter image description here

Code:

<div class="cat_btn">
<ul class="dropdown">
<li><a href="#">Categories</a>
<ul class="sub_menu">
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
<li><a href="#">Ben10</a></li>
</ul>
</li>
</ul>
</div>


CSS Code:

ul.dropdown { position: relative; -webkit-border-radius: 5px;
-moz-border-radius: 5px; border-radius: 5px;}
ul.dropdown li { font-weight: bold; float: left; zoom: 1; background: #ccc; -webkit-border-radius: 5px;
-moz-border-radius: 5px; border-radius: 5px; /*width: 100px; height: 30px;*/}
ul.dropdown a:hover { color: #000; }
ul.dropdown a:active { color: #ffa500; }
ul.dropdown li a { display: block; padding: 4px 8px; border-right: 1px solid #333;
color: #222; }
ul.dropdown li:last-child a { border-right: none; } /* Doesn't work in IE */
ul.dropdown li.hover,
ul.dropdown li:hover { background: #F3D673; color: black; position: absolute; }
ul.dropdown li.hover a { color: black; }

ul.dropdown ul { width: 220px; visibility: hidden; position: absolute; top: 100%; left: 0; -webkit-border-radius: 5px;
-moz-border-radius: 5px; border-radius: 5px; }
ul.dropdown ul li { font-weight: normal; background: #f6f6f6; color: #000;
border-bottom: 1px solid #ccc; float: none; -webkit-border-radius: 5px;
-moz-border-radius: 5px; border-radius: 5px;}
/* IE 6 & 7 Needs Inline Block */

ul.dropdown ul li a { border-right: none; width: 100%; display: inline-block; -webkit-border-radius: 5px;
-moz-border-radius: 5px; border-radius: 5px;}

Answer

Add z-index:1000 to the class ul.dropdown

Comments