const a = "transition: all 2s ease; transform: translate3d(-4.234px, 5px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg); transform-style: preserve-3d;";
const b = "transition: all 2s ease; transform: translate3d(4.234px, -5px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg); transform-style: preserve-3d;";
const c = "transition: all 2s ease; transform: translate3d(-4.234px, -5px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg); transform-style: preserve-3d;";
const d = "transition: all 2s ease; transform: translate3d(4.234px, 5px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg); transform-style: preserve-3d;";
const e = "transition: all 2s ease; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg);transform-style: preserve-3d;";
const f = "transition: all 2s ease; transform: translate3d(14px, -0.03px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg);transform-style: preserve-3d;";
const g = "transition: all 2s ease; transform: translate3d(-14px, -0.03px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg);transform-style: preserve-3d;";
const h = "transition: all 2s ease; transform: translate3d(-14px, 0.03px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg);transform-style: preserve-3d;";
const i = "transition: all 2s ease; transform: translate3d(14px, 0.03px, 0px) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg) skew(0deg, 0deg);transform-style: preserve-3d;";
const img = document.getElementById("img");
img.style.cssText = d;
const div = document.getElementById("targetbox");
div.style.cssText = f;
const anchor = document.getElementById("anchor");
anchor.style.cssText = e;
anchor.onmouseenter = function() {
img.style.cssText = b;
div.style.cssText = g;
}
anchor.onmouseover = function() {
img.style.cssText = c;
div.style.cssText = i;
}
anchor.onmousemove = function() {
img.style.cssText = a;
div.style.cssText = h;
}
anchor.onmouseout = function() {
img.style.cssText = c;
div.style.cssText = f;
}
anchor.onmouseleave = function() {
img.style.cssText = b;
div.style.cssText = i;
}
.boxtext {
color: #ffffff;
text-align: center;
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
display: inline-block;
position: relative;
}
#targetbox {
margin: 0 0 10px 5px;
}
.blackbox {
height: 75px;
width: 150px;
background-color: #000000;
position: absolute;
opacity: 0.8;
filter: alpha(opacity=50);
margin-bottom: 3px;
line-height: 7px;
left: -20px;
display: inline-block;
top: 20px;
text-align: center;
}
p {
margin: 0;
padding: 0;
color: #ffffff;
}
img {
width: 200px;
height: 200px;
}
a {
position: absolute;
margin-left: 50px;
}
<a id="anchor">
<img id="img" src="https://i0.wp.com/css-tricks.com/wp-content/uploads/2019/05/event-handlers.png?fit=1200%2C600&ssl=1" 30vw>
<div id="targetbox" class="blackbox">
<h3 class="boxtext"> Hello World </h3>
<p> Floating div</p>
</div>
</a>