-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
259 lines (241 loc) · 7.27 KB
/
index.html
File metadata and controls
259 lines (241 loc) · 7.27 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8" />
<title>電子名信片</title>
<style>
body {
background: #000;
margin: 0;
font-family: Arial, sans-serif;
color: #fff;
overflow: hidden;
}
.postcard {
max-width: 800px;
margin: 50px auto;
background: #1a1a1a;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
position: relative;
z-index: 1;
transition: opacity 1.5s ease;
}
.image-container {
position: relative;
width: 100%;
height: 400px;
overflow: hidden;
}
.image-container img {
position: absolute;
width: 100%;
height: 100%;
object-fit: cover;
top: 0;
left: 0;
transition: opacity 3s ease-in-out;
}
.image2 {
opacity: 0;
animation: fadeIn 5s forwards;
animation-delay: 2s;
}
@keyframes fadeIn {
to { opacity: 1; }
}
.hotspot {
position: absolute;
width: 4px;
height: 4px;
background-color: transparent;
border: 2px solid #00aaff;
border-radius: 50%;
cursor: pointer;
z-index: 5;
}
.zoom-area {
position: absolute;
pointer-events: none;
border-radius: 50%;
width: 120px;
height: 120px;
transform: translate(-50%, -50%);
border: 3px solid #00aaff;
overflow: hidden;
display: none;
z-index: 10;
}
.zoom-area img {
position: absolute;
width: 200%;
height: 200%;
transform: translate(-25%, -25%);
}
.tooltip {
position: absolute;
background: rgba(255, 255, 255, 0.95);
color: #000;
padding: 10px;
border-radius: 8px;
font-size: 14px;
display: none;
z-index: 20;
box-shadow: 0 0 10px rgba(255,255,255,0.3);
}
.tooltip.show {
display: block;
}
.nav-buttons {
display: flex;
justify-content: space-between;
align-items: center;
max-width: 800px;
margin: 30px auto;
padding: 20px;
font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', sans-serif;
font-size: 20px;
background: #2d2d2d;
border-radius: 15px;
box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
z-index: 1;
position: relative;
transition: opacity 1.5s ease;
}
.nav-buttons a {
text-decoration: none;
color: #ffd700;
padding: 10px 20px;
border: 2px solid #ffd700;
border-radius: 12px;
transition: all 0.3s ease;
background: rgba(255, 215, 0, 0.1);
cursor: pointer;
}
.nav-buttons a:hover {
background: #ffd700;
color: #000;
box-shadow: 0 0 10px #ffd700;
}
/* 過渡遮罩,初始是hidden */
.transition-cover {
position: fixed;
top: 0; left: 0;
pointer-events: none;
z-index: 1000;
background: #000;
opacity: 0;
transition: opacity 1.8s ease;
}
.transition-cover img {
position: absolute;
object-fit: cover;
will-change: transform, top, left, width, height, opacity;
transition:
transform 2s ease-in-out,
top 2s ease-in-out,
left 2s ease-in-out,
width 2s ease-in-out,
height 2s ease-in-out,
opacity 2s ease-in-out;
}
</style>
</head>
<body>
<div class="postcard" id="main-content">
<div class="image-container" id="image-container">
<img src="1.jpg" alt="圖片1" />
<img src="2.jpg" class="image2" alt="圖片2" id="image2" />
<div class="hotspot" id="hotspot1" style="top: 80px; left: 100px;"></div>
<div class="hotspot" id="hotspot2" style="top: 280px; left: 600px;"></div>
<div class="zoom-area" id="zoom-area"><img src="2.jpg"></div>
<div class="tooltip" id="tooltip">神龙夭矫”,这种杰出的设计继承了汉代以来的优良传统,是高水平的精神产物。</div>
</div>
</div>
<div class="nav-buttons" id="nav-buttons">
<a href="#" onclick="navigate('previous.html'); return false;">← 上一頁</a>
<a href="#" onclick="navigate('next.html'); return false;">下一頁 →</a>
</div>
<div class="transition-cover" id="transition-cover">
<img src="2.jpg" id="transition-img" alt="轉場圖片" />
</div>
<script>
const zoomArea = document.getElementById('zoom-area');
const zoomImg = zoomArea.querySelector('img');
const tooltip = document.getElementById('tooltip');
const container = document.getElementById('image-container');
const image2 = document.getElementById('image2');
const transitionCover = document.getElementById('transition-cover');
const transitionImg = document.getElementById('transition-img');
const mainContent = document.getElementById('main-content');
const navButtons = document.getElementById('nav-buttons');
// 熱區互動
const hotspots = [
{element: document.getElementById('hotspot1'), x: 100, y: 80},
{element: document.getElementById('hotspot2'), x: 600, y: 280}
];
hotspots.forEach(hs => {
hs.element.addEventListener('mouseenter', e => showZoom(e, hs));
hs.element.addEventListener('mouseleave', hideZoom);
hs.element.addEventListener('touchstart', e => { e.preventDefault(); showZoom(e, hs); });
hs.element.addEventListener('touchend', hideZoom);
});
function showZoom(event, hotspot) {
zoomArea.style.display = 'block';
tooltip.classList.add('show');
zoomArea.style.top = hotspot.y + 'px';
zoomArea.style.left = hotspot.x + 'px';
tooltip.style.top = (hotspot.y + 70) + 'px';
tooltip.style.left = (hotspot.x - 30) + 'px';
const rect = container.getBoundingClientRect();
const offsetX = (hotspot.x / rect.width) * 100;
const offsetY = (hotspot.y / rect.height) * 100;
zoomImg.style.left = `-${offsetX}%`;
zoomImg.style.top = `-${offsetY}%`;
}
function hideZoom() {
zoomArea.style.display = 'none';
tooltip.classList.remove('show');
}
// 主導航切換動畫
function navigate(url) {
// 先取得頁面中2.jpg的位置及大小
const imgRect = image2.getBoundingClientRect();
// 將過渡遮罩顯示並初始化位置大小與image2相同
transitionCover.style.opacity = '1';
transitionCover.style.pointerEvents = 'auto';
transitionCover.style.top = '0';
transitionCover.style.left = '0';
transitionCover.style.width = '100vw';
transitionCover.style.height = '100vh';
// 設定過渡圖片起始位置和大小跟頁面中圖片一樣(絕對定位)
transitionImg.style.top = imgRect.top + 'px';
transitionImg.style.left = imgRect.left + 'px';
transitionImg.style.width = imgRect.width + 'px';
transitionImg.style.height = imgRect.height + 'px';
transitionImg.style.opacity = '1';
transitionImg.style.transform = 'scale(1)';
// 隱藏主內容與導覽按鈕的透明度動畫
mainContent.style.transition = 'opacity 2s ease';
navButtons.style.transition = 'opacity 2s ease';
mainContent.style.opacity = '0';
navButtons.style.opacity = '0';
// 使用requestAnimationFrame觸發CSS transition
requestAnimationFrame(() => {
// 過渡圖片放大到全螢幕並淡出
transitionImg.style.top = '0';
transitionImg.style.left = '0';
transitionImg.style.width = '100vw';
transitionImg.style.height = '100vh';
transitionImg.style.transform = 'scale(1)'; // 因為已直接用width/height覆蓋大小,不用再scale
transitionImg.style.opacity = '0';
});
// 2秒後跳轉
setTimeout(() => {
window.location.href = url;
}, 2200);
}
</script>
</body>
</html>