Skip to content

Commit 8b902ce

Browse files
Add Pulsating Custom Cursor (#1359)
1 parent 51b9ab7 commit 8b902ce

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Document</title>
9+
<link rel="stylesheet" href="style.css">
10+
</head>
11+
12+
<body>
13+
<p>This is a <a href="#">Pulsating Custom Cursor</a></p>
14+
<div class="cursor"></div>
15+
16+
<script src="script.js"></script>
17+
</body>
18+
19+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const cursor = document.querySelector('.cursor');
2+
3+
document.addEventListener('mousemove', e => {
4+
cursor.setAttribute("style", "top: "+(e.pageY - 10)+"px; left: "+(e.pageX - 10)+"px;")
5+
})
6+
7+
document.addEventListener('click', () => {
8+
cursor.classList.add("expand");
9+
10+
setTimeout(() => {
11+
cursor.classList.remove("expand");
12+
}, 500)
13+
})
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
body {
2+
margin: 0;
3+
height: 100vh;
4+
/* cursor: none; */
5+
background: rgb(27, 27, 27);
6+
}
7+
8+
.cursor {
9+
width: 20px;
10+
height: 20px;
11+
border: 1px solid white;
12+
border-radius: 50%;
13+
position: absolute;
14+
transition-duration: 200ms;
15+
transition-timing-function: ease-out;
16+
animation: cursorAnim .5s infinite alternate;
17+
pointer-events: none;
18+
}
19+
20+
.cursor::after {
21+
content: "";
22+
width: 20px;
23+
height: 20px;
24+
position: absolute;
25+
border: 8px solid gray;
26+
border-radius: 50%;
27+
opacity: .5;
28+
top: -8px;
29+
left: -8px;
30+
animation: cursorAnim2 .5s infinite alternate;
31+
}
32+
33+
@keyframes cursorAnim {
34+
from {
35+
transform: scale(1);
36+
}
37+
38+
to {
39+
transform: scale(.7);
40+
}
41+
}
42+
43+
@keyframes cursorAnim2 {
44+
from {
45+
transform: scale(1);
46+
}
47+
48+
to {
49+
transform: scale(.4);
50+
}
51+
}
52+
53+
@keyframes cursorAnim3 {
54+
0% {
55+
transform: scale(1);
56+
}
57+
58+
50% {
59+
transform: scale(3);
60+
}
61+
62+
100% {
63+
transform: scale(1);
64+
opacity: 0;
65+
}
66+
}
67+
68+
.expand {
69+
animation: cursorAnim3 .5s forwards;
70+
border: 1px solid red;
71+
}
72+
73+
p {
74+
color: white;
75+
font-family: 'arial';
76+
text-align: center;
77+
margin-top: 50px;
78+
font-size: 1.4em;
79+
80+
a {
81+
color: teal;
82+
}
83+
}

assets/html_files/cursors.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,19 @@ <h1>Dynamic Element Tracker</h1>
148148
</a>
149149
</div>
150150
</div>
151+
<div class="box">
152+
<h1>Pulsating Custom Cursor</h1>
153+
<div class="preview">
154+
<a href="../../Components/Cursors/Pulsating-Custom-Cursor/index.html" title="Live Preview" target="_blank">
155+
<img src="../images/link.png">
156+
</a>
157+
</div>
158+
<div class="source">
159+
<a href="https://github.com/Rakesh9100/Beautiify/tree/main/Components/Cursors/Pulsating-Custom-Cursor" title="Source Code" target="_blank">
160+
<img src="../images/github.png">
161+
</a>
162+
</div>
163+
</div>
151164
</div>
152165
</section>
153166

0 commit comments

Comments
 (0)