File tree 5 files changed +93
-1
lines changed
5 files changed +93
-1
lines changed Original file line number Diff line number Diff line change
1
+ # CSS Text Shadow Mouse Move Effect
2
+ Watch this challenge live in [ codepen] ( https://codepen.io/pouyio/full/mwweaq/ ) .
Original file line number Diff line number Diff line change
1
+ window . onload = ( ) => {
2
+ const body = document . querySelector ( 'body' ) ;
3
+ const text = document . querySelector ( '.text' ) ;
4
+ const walk = 100 ;
5
+
6
+ const shadow = ( e ) => {
7
+ const { offsetWidth : width , offsetHeight : height } = body ;
8
+ let { offsetX : x , offsetY : y } = e ;
9
+ if ( this !== e . target ) {
10
+ x = x + e . target . offsetLeft ;
11
+ y = y + e . target . offsetTop ;
12
+ }
13
+
14
+ const xWalk = Math . round ( x / width * walk ) - ( walk / 2 ) ;
15
+ const yWalk = Math . round ( y / width * walk ) - ( walk / 2 ) ;
16
+
17
+ console . log ( xWalk , yWalk ) ;
18
+ text . style . textShadow = `${ xWalk } px ${ yWalk } px 0 red` ;
19
+ }
20
+ body . addEventListener ( 'mousemove' , shadow ) ;
21
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < title > CSS Text Shadow Mouse Move Effect</ title >
6
+ < style media ="screen ">
7
+ body {
8
+ font-family : sans-serif;
9
+ font-size : 1.8em ;
10
+ color : # 383838 ;
11
+ min-height : 100vh ;
12
+ margin : 0 ;
13
+ padding : 1em ;
14
+ box-sizing : border-box;
15
+ background-color : # e7e4e4 ;
16
+ display : flex;
17
+ flex-direction : column;
18
+ justify-content : space-around;
19
+ align-items : center;
20
+ }
21
+ </ style >
22
+ </ head >
23
+ < body >
24
+ < h1 class ="text "> Chimichanga 🌮</ h1 >
25
+ < script type ="text/javascript " src ="./app.js ">
26
+ </ script >
27
+ </ body >
28
+ </ html >
Original file line number Diff line number Diff line change
1
+ body {
2
+ font-family : sans-serif;
3
+ color : # 383838 ;
4
+ font-size : 1.5rem ;
5
+ min-height : 100vh ;
6
+ padding : 1em ;
7
+ box-sizing : border-box;
8
+ background-color : # e7e4e4 ;
9
+ display : flex;
10
+ flex-direction : column;
11
+ justify-content : center;
12
+ align-items : center;
13
+ max-width : 600px ;
14
+ margin : 0 auto;
15
+ }
16
+
17
+ .content {
18
+ text-align : justify;
19
+ }
20
+
21
+ img {
22
+ width : 220px ;
23
+ height : auto;
24
+ padding : .8em ;
25
+ opacity : 0 ;
26
+ transition : all .5s ;
27
+ }
28
+
29
+ .al-right {
30
+ float : right;
31
+ padding-right : 0 ;
32
+ }
33
+
34
+ .al-left {
35
+ float : left;
36
+ padding-left : 0 ;
37
+ }
38
+
39
+ .active {
40
+ opacity : 1 ;
41
+ }
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ My goal is simply to learn the basics by doing many simple things rather than st
20
20
13 . [x] [ Slide in on Scroll] ( ./13-slide-in-on-scroll ) - [ Codepen] ( http://codepen.io/pouyio/full/ENzdzv/ )
21
21
14 . [x] [ JavaScript References vs. Copying] ( ./14-reference-copying ) - [ Codepen] ( https://codepen.io/pouyio/pen/wegbpP )
22
22
15 . [x] [ LocalStorage] ( ./15-localStorage ) - [ Codepen] ( https://codepen.io/pouyio/full/XgRpOd/ )
23
- 16 . [ ] Mouse Move Shadow
23
+ 16 . [x] [ CSS Text Shadow Mouse Move Effect ] ( ./16-text-shadow ) - [ Codepen ] ( https://codepen.io/pouyio/full/mwweaq/ )
24
24
17 . [ ] Sort Without Articles
25
25
18 . [ ] Adding Up Times with Reduce
26
26
19 . [ ] Webcam Fun
You can’t perform that action at this time.
0 commit comments