JSFiddle - React, Tailwind, and code Playground

by Serhii Matrunchyk

HTML

<div class="container">
  <div id="canvas"></div>
  <div id="dot"></div>
</div>

CSS

body, html {
  margin: 0;
  padding: 0;
}

.container {
  zoom: 60%;
}

#canvas {
  height: 100vh;
  width: 100vw;
  background: lightblue;
}

#dot {
  height: 9px;
  width: 9px;
  border-radius: 100%;
  background: darkblue;
  transform: translate(-50%, -50%);
  position: absolute;
  left: 0;
  top: 0;
}

JavaScript

window.onload = () => {
  const dot = document.querySelector('#dot');

console.log(dot, document.querySelector('#canvas'))
  document.querySelector('#canvas').addEventListener('mousemove', (event) => {
    dot.style.left = event.clientX + 'px';
    dot.style.top = event.clientY + 'px';
  })
}