File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ let innerCursor = document . querySelector ( ".inner-cursor" ) ;
2+ let outerCursor = document . querySelector ( ".outer-cursor" ) ;
3+
4+ document . addEventListener ( "mousemove" , moveCursor ) ;
5+
6+ function moveCursor ( e ) {
7+ let x = e . clientX ;
8+ let y = e . clientY ;
9+
10+ innerCursor . style . left = `${ x } px` ;
11+ innerCursor . style . top = `${ y } px` ;
12+ outerCursor . style . left = `${ x } px` ;
13+ outerCursor . style . top = `${ y } px` ;
14+ }
Original file line number Diff line number Diff line change 1+ < html lang ="en ">
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Custom Cursor</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ </ head >
9+ < body >
10+ < div class ="inner-cursor "> </ div >
11+ < div class ="outer-cursor "> </ div >
12+
13+ < script src ="app.js "> </ script >
14+ </ body >
15+ </ html >
Original file line number Diff line number Diff line change 1+ * {
2+ margin : 0 ;
3+ padding : 0 ;
4+ box-sizing : border-box;
5+ font-family : sans-serif;
6+ cursor : none;
7+ }
8+
9+ body ,
10+ html {
11+ width : 100% ;
12+ height : 200vh ;
13+ background-color : white;
14+ }
15+
16+ .inner-cursor {
17+ position : fixed;
18+ left : 10px ;
19+ width : 10px ;
20+ height : 10px ;
21+ transform : translate (-50% , -50% );
22+ background : white;
23+ mix-blend-mode : difference;
24+ border-radius : 50% ;
25+ pointer-events : none;
26+ transition : width 0.5s height 0.5s ;
27+ }
28+
29+ .outer-cursor {
30+ position : fixed;
31+ left : 10px ;
32+ width : 25px ;
33+ height : 25px ;
34+ transform : translate (-50% , -50% );
35+ border : 1px solid white;
36+ mix-blend-mode : difference;
37+ border-radius : 50% ;
38+ pointer-events : 0.1ms ;
39+ transition : 0.1s ;
40+ }
You can’t perform that action at this time.
0 commit comments