<div id="headContainer">
<div id="blackBar">
<div class="content">
<img src="../Images/logo.png" class="logo" alt="logo" />
<div id="clientSettings">
<div id="settingsContainer">
<ul>
<li><asp:LinkButton ID="endSession" OnClick="endSession_Click" Text="Exit" runat="server" /></li>
<li>not available</li>
</ul>
</div>
</div>
<div id="clientProfile"></div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#clientSettings').click(function () {
$('#settingsContainer').toggle();
});
});
</script>
<div id="grayBar">
</div>
</div>
Alright, So as you might guess from above, I am trying to show #settingsContainer once #clientSettings has been clicked by using jQuery. I am able to achieve that with the .toggle() method. However, #settingsContainer needs to overlap #grayBar.
Please see below the CSS:
headContainer:
#headContainer
{
top : 0;
left : 0;
width : 100%;
height : 100px;
position : fixed; <- or relative doesn't matter.
z-index : 1;
}
#headContainer div#grayBar
{
top : 0;
left : 0;
position : relative; <- or fixed doesn't matter.
width : 100%;
height : 50px;
background-color : #f1f1f1;
z-index : 1;
}
clientSettings + settingsContainer:
#headContainer div#blackBar div#clientSettings
{
float : left;
position : relative;
width : 25px;
height : 50px;
background-image : url('../Images/Icons/endSession.png');
background-repeat : no-repeat;
background-position : center center;
}
#headContainer div#blackBar div#clientSettings:hover
{
cursor : pointer;
background-color : #636363;
}
#headContainer div#blackBar div#clientSettings #settingsContainer
{
position : relative; <- tried using absolute instead.
top : 50px;
left : 0;
padding : 50px;
background-color : Green;
z-index : 99999; <- doesn't really matter.
}
I am trying to figure out a way to have #settingsContainer overlap its parents and everything else while keeping it as a child of #clientSettings.
Thank you.
This is because of
float:leftin#clientSettings, floated elements comes out of the browser’s draw flow, so they start behave similar toposition:absoluteelements. You can either removefloat:leftor start using z-index (in both#settingsContainerand#clientSettings). Here is working demo with your code.