-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (48 loc) · 1.46 KB
/
script.js
File metadata and controls
53 lines (48 loc) · 1.46 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
// 平滑滚动效果
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// 添加页面加载动画
window.addEventListener('load', () => {
document.body.style.opacity = '0';
setTimeout(() => {
document.body.style.transition = 'opacity 0.5s ease-in';
document.body.style.opacity = '1';
}, 100);
});
// 联系方式的交互效果
document.querySelectorAll('.contact-item').forEach(item => {
item.addEventListener('mouseenter', function() {
this.style.transform = 'translateX(5px)';
});
item.addEventListener('mouseleave', function() {
this.style.transform = 'translateX(0)';
});
});
// 技能标签的点击效果
document.querySelectorAll('.skill-tag').forEach(tag => {
tag.addEventListener('click', function() {
this.style.animation = 'pulse 0.3s ease';
setTimeout(() => {
this.style.animation = '';
}, 300);
});
});
// 添加脉冲动画
const style = document.createElement('style');
style.textContent = `
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.1); }
}
`;
document.head.appendChild(style);