(function() { var background = document.getElementById('background'); window.addEventListener('mousemove', function (event) { var newX = (event.clientX / document.body.clientWidth * 2 - 1); var newY = (event.clientY / document.body.clientHeight * 2 - 1); background.style.top = -newY + "vh"; background.style.left = -newX + "vw"; }) })();