-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_former.html
166 lines (145 loc) · 5.12 KB
/
index_former.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome My World!</title>
<link href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.css' rel='stylesheet' />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
<style>
body,
html {
cursor: none;
}
body {
height: 100vh;
background: #171616;
justify-content: center;
align-items: center;
display: flex;
overflow: hidden;
font-family: "Press Start 2P", system-ui;
font-weight: 400;
font-style: normal;
}
.item {
width: 100%;
font-size: 50px;
color: #dabea7;
font-weight: bold;
text-align: center;
}
#myCursor {
width: 20px;
height: 20px;
border-radius: 0;
position: absolute;
color: #dabea7;
/* box-shadow: 0px 0px 1px 2px #dabea7; */
/* box-sizing: border-box */
}
#myCircle {
width: 20px;
height: 20px;
border-radius: 50%;
position: absolute;
color: #dabea7;
/* box-shadow: 0px 0px 3px 3px #dabea7; */
/* box-sizing: border-box */
}
#myD {
width: 20px;
height: 20px;
border-radius: 50%;
position: absolute;
color: #dabea7;
/* box-shadow: 0px 0px 3px 3px #dabea7; */
/* box-sizing: border-box */
}
#myE {
width: 20px;
height: 20px;
border-radius: 50%;
position: absolute;
color: #dabea7;
/* box-shadow: 0px 0px 3px 3px #dabea7; */
/* box-sizing: border-box */
}
#myCursor,
#myCircle,
#myD,
#myE {
pointer-events: none;
}
</style>
</head>
<body>
<div class="container">
<div class="item">HTML</div>
<div class="item">CSS</div>
<div class="item">JavaScript</div>
<div class="item">PHP</div>
<div class="item">MySQL</div>
<div class="item">
<a href="collections.html" type="button" class="btn btn-light">ENTER</a>
</div>
</div>
<i class="fa-solid fa-c mx-0" id="myCursor"></i>
<i class="fa-solid fa-o mx-0" id="myCircle"></i>
<i class="fa-solid fa-d mx-0" id="myD"></i>
<i class="fa-solid fa-e mx-0" id="myE"></i>
<!-- bootstrap -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.js'></script>
<!-- jQuery -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js'></script>
<!-- 引入 gsap 主程式 -->
<script src="./gsap/gsap.js"></script>
<script>
// set 設定初始補間動畫的預設值
gsap.set('.container', {
perspective: 1000,
})
const tl = gsap.timeline({
// repeat: -1,
// repeatDelay: 0.3,
})
tl
.from('.item', {
y: 60,
rotationX: -90,
autoAlpha: 0, // 元素會變得完全透明,使其在畫面上不可見
stagger: 1.2, // 每個 .item 元素動畫將以 1.2 秒的間隔依次執行
})
.to('.item', {
y: -60,
// rotationX: 90,
autoAlpha: 1,
stagger: 1.2,
}, 1.2) // 第三參數只設定動畫在時間軸的位置,表示把動畫放在時間軸1.2秒的位置
// 追蹤滑鼠
let cursor = document.getElementById("myCursor");
let circle = document.getElementById("myCircle");
let letterD = document.getElementById("myD");
let letterE = document.getElementById("myE");
window.addEventListener("mousemove", function (e) { // 當在瀏覽器中移動滑鼠時觸發,將執行指定的函數(e)
let x = e.clientX; // 獲取了滑鼠在瀏覽器視窗中的 X 座標,並存儲在變數 x 中
let y = e.clientY; // 獲取了滑鼠在瀏覽器視窗中的 Y 座標,並存儲在變數 y 中
cursor.style.left = x - 10 + "px"; //
cursor.style.top = y - 10 + "px";
setTimeout(() => {
circle.style.left = x - 10 + "px"; // x 軸差15px 可排出文字
circle.style.top = y - 10 + "px";
}, 100); // 設定延遲時間
setTimeout(() => {
letterD.style.left = x - 10 + "px";
letterD.style.top = y - 10 + "px";
}, 200);
setTimeout(() => {
letterE.style.left = x - 10 + "px";
letterE.style.top = y - 10 + "px";
}, 300);
})
</script>
</body>
</html>