Created
April 29, 2020 22:33
-
-
Save jensen/b34bbdfbc2d37cf671a72c5e18a53b06 to your computer and use it in GitHub Desktop.
Creating a custom cursor with vanilla JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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