So I have this div class:
<div id="object1">
<div class="title" onmouseover="hoverImage(event)">SPT 3</div>
</div>
And outside of that div, I have another div with a image:
<div class="hover_img" id="hover_img">
<img src="img/sptgoal.PNG">
</div>
CSS code to center the image:
.hover_img {
position:relative;
height: 100%;
width:100%;
z-index: 99;
}
.hover_img img {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display:none;
}
I only want the image to be visible when hovering the div. This is the Javascript code I have:
function hoverImage() {
var x = document.getElementById("hover_img");
x.style.display = "block";
}
But when hovering the mouse over, nothing shows up. What am I doing wrong here?