<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>个人网页</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background: #000;
color: #fff;
font-family: Arial, sans-serif;
}
.stars {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.star {
position: absolute;
background: #fff;
border-radius: 50%;
animation: twinkle 1s infinite;
}
@keyframes twinkle {
0% { opacity: 0; transform: scale(0); }
50% { opacity: 1; transform: scale(1); }
100% { opacity: 0; transform: scale(0); }
}
</style>
</head>
<body>
<div class="stars"></div>
<!-- Your content goes here -->
<h1>Welcome to My Personal Website</h1>
<p>This is where you can showcase your information, projects, and more!</p>
<script>
const stars = document.querySelector('.stars');
for (let i = 0; i < 100; i++) {
const star = document.createElement('div');
star.className = 'star';
star.style.top = Math.random() * 100 + 'vh';
star.style.left = Math.random() * 100 + 'vw';
star.style.width = Math.random() * 2 + 1 + 'px';
star.style.height = star.style.width;
star.style.animationDuration = Math.random() * 2 + 1 + 's';
stars.appendChild(star);
}
</script>
</body>
</html>
这段代码会在页面背景生成很多闪烁的星星,给你的个人网页带来动态繁星背景特效。你可以将自己的个人信息、项目等内容添加到 <body>
标签内,使网页更加完整。如果需要更多的样式调整或功能扩展,可以进一步修改代码。