I read that z-index positive and greater than other divs should stack the div on top of others with lower z-index. Why does the identified div move, and how do I prevent this? This question different from asking about display:none vs visibility because the z-index should allow for layering divs from an x, y 2-dimension plane to a third dimension, z.
http://jsfiddle.net/9RxLM/5832/
var mouseX;
var mouseY;
$(document).mousemove(function(e) {
mouseX = e.pageX + 20;
mouseY = e.pageY - 20;
});
$(".dimoption").click(function() {
var $maxdim = $("#msgmaxdim");
$maxdim.css({
'top': mouseY,
'left': mouseX
}).fadeIn('slow');
setTimeout(function() {
$maxdim.fadeOut('slow');
}, 3000);
});
.description {
display: none;
position: relative;
border: 1px solid #000;
width: 400px;
background-color: white;
z-index: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" class="dimoption">Text
<div id="msgmaxdim" class="description">Popup overlay</div>
<div id="othercontent">
Why does this div move?
</div>