-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
37 lines (34 loc) · 1.16 KB
/
main.js
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
// Create twinkling stars effect
function createStars() {
const starsContainer = document.querySelector('.stars');
const numberOfStars = 200;
for (let i = 0; i < numberOfStars; i++) {
const star = document.createElement('div');
star.className = 'star';
star.style.cssText = `
position: absolute;
width: 2px;
height: 2px;
background: white;
border-radius: 50%;
left: ${Math.random() * 100}%;
top: ${Math.random() * 100}%;
animation: twinkle ${1 + Math.random() * 3}s infinite;
opacity: ${0.5 + Math.random() * 0.5};
`;
starsContainer.appendChild(star);
}
}
// Smooth scroll for navigation
document.querySelectorAll('nav a').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
targetSection.scrollIntoView({ behavior: 'smooth' });
});
});
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
createStars();
});