Guest User

Untitled

a guest
Mar 21st, 2026
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | Help | 0 0
  1. HTML:
  2.  
  3. <img style ="padding-top: 20px;" class = "cursor" src=images/cursor/wii-pointer-ccw.png /> <!-- imports custom cursor -->
  4.  
  5.  
  6. CSS:
  7. body {
  8. cursor:none;
  9. }
  10.  
  11. .cursor {
  12. width: 2em;
  13. height: 2em;
  14. position: absolute;
  15. pointer-events: none;
  16. }
  17.  
  18. JS:
  19.  
  20. const cursor = document.querySelector(".cursor")
  21.  
  22. document.addEventListener("mousemove", (event) => {
  23.  
  24. const {width, height} = cursor.getBoundingClientRect()
  25.  
  26. cursor.style.left = `${event.clientX - width / 2}px`
  27. cursor.style.top = `${event.clientY - height / 2}px`
  28.  
  29.  
  30. })
  31.  
Tags: html CSS jss
Advertisement
Add Comment
Please, Sign In to add comment