I have a problem with my select box is that my options overlap with the green div even if I use a high Z-index :
.my-navbar {
position: fixed;
width: 500px;
height: 40px;
background-color: orange;
}
.my-div1 {
position relative;
}
.my-div1 {
position absolute;
height: 100px;
width: 120px;
background-color: green;
z-index: 1000;
}
.my-main {
padding-top: 50px;
}
.my-select {
width: 150px;
margin-left: 30px;
z-index: 1;
}
<div class="my-navbar">
<div>My navbar</div>
<div class="my-div1">
<div class="my-div2">
<ul>
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ul>
</div>
</div>
</div>
<div class="my-main">
<select class="my-select">
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
</select>
</div>
My green div has an absolute position but why z-index not working in this case ?
The example below is just a prototype and really the green div is displayed in hover, it is a menu element but if I click on the select box and I display the green div, it overlapped by the select options