Skip to content

Commit 0d41939

Browse files
committed
day 16
1 parent 047cb93 commit 0d41939

File tree

5 files changed

+93
-1
lines changed

5 files changed

+93
-1
lines changed

16-text-shadow/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# CSS Text Shadow Mouse Move Effect
2+
Watch this challenge live in [codepen](https://codepen.io/pouyio/full/mwweaq/).

16-text-shadow/app.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

16-text-shadow/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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>

16-text-shadow/style.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ My goal is simply to learn the basics by doing many simple things rather than st
2020
13. [x] [Slide in on Scroll](./13-slide-in-on-scroll) - [Codepen](http://codepen.io/pouyio/full/ENzdzv/)
2121
14. [x] [JavaScript References vs. Copying](./14-reference-copying) - [Codepen](https://codepen.io/pouyio/pen/wegbpP)
2222
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/)
2424
17. [ ] Sort Without Articles
2525
18. [ ] Adding Up Times with Reduce
2626
19. [ ] Webcam Fun

0 commit comments

Comments
 (0)