My question is similar to CSS: How to have position:absolute div inside a position:relative div not be cropped by an overflow:hidden on a container.
I have a very long vertical menu that shows a submenu on hover. I want to make the menu fixed and 100% height on my page and use a scroll bar to scroll menu items. I will use jquery slimScroll to show the scroll bar which needs the parent container to have overflow: hidden.
The issue is that the submenu will not show over the parent container if it has overflow: hidden. Html code:
<div class="scrollable">
<ul class="menu">
<li>Menu
<ul class="submenu">
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
<li>Menu
<ul class="submenu">
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
<li>Menu
<ul class="submenu">
<li>Submenu</li>
</ul>
</li>
<li>Menu
<ul class="submenu">
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
<li>Menu
<ul class="submenu">
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
</ul>
CSS code:
/* this needs to have a fixed position */
.scrollable {
/* If i remove the fixed position the ul's will go outside */
position: fixed;
top: 0;
left: 0;
overflow: hidden;
/*
overflow-y: scroll;
overflow-x: hidden;
overflow-x: visible;
*/
width: 100px;
height: 100px;
border: 1px solid #ff0000;
padding: 10px;
}
ul {
margin: 0;
padding: 0;
list-style-type: none;
position: absolute;
}
li {
width: 100px;
background-color: #dddddd;
line-height: 50px;
height: 50px;
border-bottom: 1px solid #fff;
display: block;
/* even if I set position to absolute, which messes the design, the submenu wont show outside */
/* position: absolute; */
}
.submenu {
display:none;
margin: -45px 0 0 70px;
border: 1px solid #000;
position: absolute;
z-index: 100;
}
.menu li:hover .submenu {
display: block;
}
I have an example of striped html and css here jsfiddle.
Is there a way to show the submenu over the container with overflow:hidden?