<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=">
<title>Cursor Animation on MouseMove Using Javascript</title>
</head>
<body>
<div class="content">
<!-- <h1>Cursor pointer animation on mouse move</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Debitis omnis ipsam voluptatibus impedit quod dolor soluta id suscipit expedita aspernatur. Autem omnis, fugit reprehenderit unde maxime harum vitae incidunt? Sint.
</p> -->
</div>
<div class="cursor"></div>
<div class="cursor2"></div>
</body>
</html>
body
{
margin: 0;
padding: 0;
background: url(https://source.unsplash.com/1600x900/?moon) no-repeat center;
background-size: cover;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-family: "open sans",sans-serif;
color: #fff;
cursor: pointer;
}
.content p
{
width: 700px;
line-height: 26px;
font-size: 18px;
text-align: justify;
}
.cursor
{
position: fixed;
width: 50px;
height: 50px;
border: 1px solid #c6c6c6;
border-radius: 50%;
left: 0;
top: 0;
pointer-eventd: none;
transform: translate(-50%, -50%);
transition: .1s;
}
.cursor2
{
position: fixed;
width: 0px;
height: 0px;
background-color: #c6c6c6;
border-radius: 50%;
left: 0;
top: 0;
pointer-eventd: none;
transform: translate(-50%, -50%);
}
var cursor = document.querySelector(".cursor");
var cursor = document.querySelector(".cursor");
document.addEventListener("mousemove", function(e){
cursor.style.cssText = cursor.style.cssText = "left: " + e.clientX + "px; top: " + e.clientY + "px;";
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.