This has been asked before but none of the answers seem to be working for me.
My issue is related to a lost z-index when a transformation is applied.
I have an overlay div with a defined z-index, it has a sibling with no z-index and this div contains a child with a z-index greater than the overlay. This child can be dragged around.
At some point I rotate this sibling and it's child loses the z-index.
How can I prevent this from happening?
I tried several solutions attemps like transform-style: flat; or transform-style: preserve-3d; but with no luck
This is the code
HTML
<div class="main">
  <div class="some_container">
    <div class="drag"></div>
  </div>
</div>
<div class="overlay"></div>
<br><br><br>
<button>rotate!</button>
CSS
body {
    padding: 20px
}
div {
    border: 1px solid black;
    width: 50px;
    height: 50px;
}
.main {
    border: 1px dashed blue;
    padding: 15px;
}
.some_container {
    position: relative;
    background-color: green;
}
.overlay {
    background-color: red;
    position: absolute;
    left: 35px;
    top: 35px;
    z-index: 5
}
.drag {
    position: relative;
    width: 30px;
    height: 30px;
    background-color: lime;
    z-index: 10;
    cursor: move;
}
.rotated {
    transform: rotateZ(15deg);
}
.rotated .drag {
    background-color: yellow;
    transform: rotateZ(-15deg);
    position: relative;
    z-index: 100;
  transform-style: flat;
}
JS
$(".drag").draggable();
$("button").click(function()
{
    $(".some_container").addClass("rotated");
});
fiddle: https://jsfiddle.net/2zkn9dap/
 
     
    