I created Div Over Image button css style postion is absolute when i scroll the pages the div also scrolling down how can i fix the dive over image button
#DamageDiv {
background-color:red;
position:absolute;
z-index:1000;/* heighest z-index show on top */
}
function DrawImage(e) {
var evt = e || window.event; // compliant with ie6
var posX = evt.clientX;
var posY = evt.clientY;
var iDiv = document.createElement('div');
iDiv.id = DamageType;
iDiv.style.top = posY + "px";
iDiv.style.left = posX + "px";
iDiv.style.width = "20px";
iDiv.style.height = "20px";
document.getElementsByTagName('body')[0].appendChild(iDiv);
}
Remove the position:absolute
from your CSS - this makes the div stay in the same place on the screen when you scroll.
Read here: Difference between style = "position:absolute" and style = "position:relative"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.