I have HTML structure
<div class="PapaDiv">
<input type="checkbox"/>
<label></label>
<div class="ChildDiv">
<input type="radio"/><label></label>
<input type="radio"/><label></label>
<input type="radio"/><label></label>
</div>
<br/>
</div>
This animal is being constructed dynamically server side depending on the data. This is kind of like a nested menu. When the user mouseovers a checkbox with label, the ChildDiv is displayed next to it. PapaDiv has overflow-y:auto
and max height defined.
So, if there are a lot of checkboxes, PapaDiv gets a vertical scroll bar. This is the wanted behavior. Now, if you mouseover the bottom checkbox, its ChildDiv also gets displayed inside PapaDiv (overflow-y:auto
). And the business wants it to be displayed on top of PapaDiv for which I would have to set overflow-y:visible
.
That's the dilemma here. I need a mix of both behaviors. I need ChildDiv to display outside PapaDiv and at the same time the other children to be inside with scrollbar displayed if there are lots of them. Is there a solution to this?
EDIT: I don't think this would help much, but here is the CSS:
.ChildDiv{
background-color: #EDF1F9;
border: 1px solid #557AB5;
display: none;
max-height: 200px;
overflow-y: auto;
padding: 10px;
position: absolute;
}
.PapaDiv{
background-color: #FFFFFF;
border: 1px solid #557AB5;
box-shadow: 3px 3px 7px rgba(0, 0, 0, 0.3);
left: 0;
max-height: 300px;
overflow-y: auto;
padding: 0.5em;
position: absolute;
top: 0;
width: 98%;
z-index: 501;
}
PapaDiv's parent div {
position: relative;
width: 100%;
}
EDIT: The reason nothing shows up is because there are display:none
's in CSS. There is JavaScript involved. For these elements, on mouseover on checkbox or its label, ChildDiv shows up (jQuery $('.ChildDiv').show()
).
On mouseout from ChildDiv or PapaDiv: $('.ChildDiv').hide()
. Also, there is a simple calculation involved to set "top" and "left" properties for ChildDiv so it appears next to its checkbox. ChildDiv is already defined with position:absolute;
.