I'm creating a dropdown settings box, and inside it I want to be able to have dropdown submenus to group settings. The submenus should slide down, and to do so, I am using jQuery to slide down the div that contains them. However, the absolutely positioned toggles that I have appear immediately, despite the fact that they are outside the div, which is set to overflow: hidden
, as can be seen in this image:
This is a sample from my html:
<div id="settings-content" class="hover-content">
<div class="setting-expandable">
Panels to display<span class="expand-button pointer">+</span>
<div class="hide expand-content">
<label class="pointer">YouTube - LinusTechTips
<input type="checkbox" class="display-none setting" data-setting="panel.yt.ltt"><span class="toggle"></span>
</label>
<br/>
<label class="pointer">YouTube - TechQuickie
<input type="checkbox" class="display-none setting" data-setting="panel.yt.tq"><span class="toggle"></span>
</label>
<br/>
<label class="pointer">YouTube - Channel Superfun
<input type="checkbox" class="display-none setting" data-setting="panel.yt.csf"><span class="toggle"></span>
</label>
<br/>
</div>
</div>
</div>
and my CSS:
.toggle {
height: 13px;
margin: 3px 0;
position: absolute;
right: 10px;
width: 27px;
}
.toggle::after {
background - color: red;
content: "";
height: 13px;
position: absolute;
right: 0;
width: 13px;
transition: 0.2s linear all;
}
.expand-content {
margin-left: 10px;
margin-top:3px;
overflow:hidden
}
.hover-content {
position: absolute;
width: 500px;
right: 15px;
background-color: inherit;
top: -15px;
border: 2px black solid;
border-radius: 14px;
padding: 5px;
display: block;
}
JS is essentially $("...").click(function(){ $("...").slideUp(); });
If I deliberately position them outside of the content area, and set overflow hidden on each thing in turn, it only hides when it affects the #settings-content
container div.
I have made a fiddle for it here: http://jsfiddle.net/S4DSh/1/
I would greatly appreciate some guidance as to how I should fix this because it looks pretty weird at the moment.
Thanks in advance!