JSFiddle - React, Tailwind, and code Playground
by vusan
HTML
<div id="box"></div>
CSS
div#box {
background-image:url(http://i.stack.imgur.com/YOUgO.gif);
width:50px;height:50px;
position:relative;
}
#box:hover {
cursor:none;
}
}
JavaScript
var elem = document.getElementById('box');
var PositionX = 0;
var PositionY = 0;
var MouseX = 0
var MouseY = 0;
var mouseDown = true;
document.onmousemove = function(e) {
if (mouseDown) {
elem.style.left = PositionX + e.clientX - MouseX-25 + "px";
elem.style.top = PositionY + e.clientY - MouseY -25 +"px";
}
};