I have some HTML with two divs:
-
Have the style for the parent div and the child divs' set as following. It worked for my case, hope it helps you as well..
in your JS:
document.getElementById('parentDiv').style.position = 'relative';
document.getElementById('backdrop').style.position = 'absolute';
document.getElementById('curtain').style.position = 'absolute';
document.getElementById('curtain').style.zIndex= '2';//this number has to be greater than the zIndex of 'backdrop' if you are setting any
or in your CSS as in this working example:::
#parentDiv{
background: yellow;
height: 500px;
width: 500px;
position: relative;
}
#backdrop{
background: red;
height: 300px;
width: 300px;
position: absolute;
}
#curtain{
background: green;
height: 100px;
width: 100px;
position: absolute;
z-index: 2;
margin: 100px 0px 150px 100px;
}
THIS IS PARENT DIV
THIS IS BACKDROP DIV
THIS IS CURTAIN DIV