Skip to content

Instantly share code, notes, and snippets.

@jensen
Created April 29, 2020 22:33
Show Gist options
  • Save jensen/b34bbdfbc2d37cf671a72c5e18a53b06 to your computer and use it in GitHub Desktop.
Save jensen/b34bbdfbc2d37cf671a72c5e18a53b06 to your computer and use it in GitHub Desktop.
Creating a custom cursor with vanilla JS
<div>?</div>
div {
position: absolute;
bottom: 0;
right: 0;
}
* {
cursor: none;
}
document.addEventListener("mousemove", (event) => {
const crossHair = document.querySelector("div");
crossHair.style.top = `${event.clientY}px`;
crossHair.style.left = `${event.clientX}px`;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment