Last active
December 24, 2020 21:50
-
-
Save sharjeel619/fb7b9f170ddf670d102e958128346498 to your computer and use it in GitHub Desktop.
Implementing simple custom circular mouse pointer
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
<html> | |
<head> | |
<style> | |
body { | |
background: #111; | |
cursor: none; | |
} | |
.cursor { | |
width: 30px; | |
height: 30px; | |
border: 1.5px solid #fff; | |
z-index: 999; | |
border-radius: 50%; | |
position: absolute; | |
transition: .15s all ease-out; | |
pointer-events: none; | |
} | |
.cursor::after { | |
content: ""; | |
position: absolute; | |
width: 2px; | |
height: 2px; | |
background-color: #fff; | |
left: 13.7px; | |
top: 13.5px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="cursor"></div> | |
<script> | |
const elem = document.querySelector(".cursor"); | |
document.addEventListener("mousemove", (e) => { | |
elem.setAttribute("style", `-webkit-transform: translate(${e.pageX}px, ${e.pageY}px); transform: translate(${e.pageX}px, ${e.pageY}px);`); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment