I have multiply divs
in my html
where i want to overlay a window. It is no problem to set the overlay to the correct position of my div
with position: aboslute
and top
and left
but when i resize the window or scroll the overlay is not moving with the element. How can i do that simple?
function showDetails(e, elem) {
var parentPosition = getPosition(e.currentTarget);
var overlay = document.getElementById("overlay");
overlay.style.top = parentPosition.y;
overlay.style.left = parentPosition.x;
}
html:
<body>
<div class="content">
<div class="button" onclick="showDetails(event,this)"></div>
<div class="button" onclick="showDetails(event,this)"></div>
<div class="button" onclick="showDetails(event,this)"></div>
</div>
<div id="overlay"></div>
</body>
Aucun commentaire:
Enregistrer un commentaire