设计思路
我们将创建一个单页面应用,采用“一页滚动”(One-Page Scroll)的设计风格,让访客可以流畅地浏览你的所有信息。

(图片来源网络,侵删)
页面结构:
- 导航栏: 固定在顶部,方便用户在不同部分间快速跳转。
- 英雄区: 首屏大图,包含你的名字、职位和一句引人注目的介绍语,以及一个 CTA (Call to Action) 按钮。
- 关于我: 简要介绍你的背景、技能和热情所在。
- 技能/专长: 以视觉化的方式(如进度条或图标)展示你的技术栈。
- 项目展示: 精选你的作品集,使用卡片式布局,每个项目包含标题、描述和链接。
- 联系方式: 提供多种联系方式,如邮箱、社交媒体链接等。
- 页脚: 包含版权信息等。
第一步:HTML 结构
我们搭建页面的骨架,使用语义化标签不仅对 SEO 友好,也让代码结构更清晰。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">你的名字 - 个人主页</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body>
<!-- 导航栏 -->
<nav class="navbar">
<div class="navbar-container">
<a href="#home" class="navbar-logo">你的名字</a>
<ul class="navbar-menu">
<li><a href="#home" class="nav-link">首页</a></li>
<li><a href="#about" class="nav-link">关于我</a></li>
<li><a href="#skills" class="nav-link">技能</a></li>
<li><a href="#projects" class="nav-link">项目</a></li>
<li><a href="#contact" class="nav-link">联系</a></li>
</ul>
</div>
</nav>
<!-- 英雄区 -->
<section id="home" class="hero">
<div class="hero-content">
<h1>你好,我是 <span class="highlight">你的名字</span></h1>
<p class="subtitle">一个充满热情的 <span id="typed-text">前端开发者</span></p>
<a href="#contact" class="cta-button">联系我</a>
</div>
</section>
<!-- 关于我 -->
<section id="about" class="about">
<div class="container">
<h2 class="section-title">关于我</h2>
<div class="about-content">
<div class="about-text">
<p>你好!我是一名专注于创造优美、高效网络体验的前端开发者,我热爱将复杂的问题转化为简洁、优雅的代码和设计。</p>
<p>拥有多年的行业经验,我精通 HTML5, CSS3, JavaScript 以及现代前端框架如 React 和 Vue,我相信持续学习和分享知识是成长的关键。</p>
<p>在工作之余,我喜欢探索新技术、阅读技术博客,并参与开源项目。</p>
</div>
<div class="about-image">
<img src="https://via.placeholder.com/400x500" alt="你的照片">
</div>
</div>
</div>
</section>
<!-- 技能 -->
<section id="skills" class="skills">
<div class="container">
<h2 class="section-title">我的技能</h2>
<div class="skills-grid">
<div class="skill-item">
<i class="fab fa-html5"></i>
<h3>HTML5</h3>
<div class="skill-bar">
<div class="skill-level" style="width: 95%;"></div>
</div>
</div>
<div class="skill-item">
<i class="fab fa-css3-alt"></i>
<h3>CSS3 / SASS</h3>
<div class="skill-bar">
<div class="skill-level" style="width: 90%;"></div>
</div>
</div>
<div class="skill-item">
<i class="fab fa-js"></i>
<h3>JavaScript</h3>
<div class="skill-bar">
<div class="skill-level" style="width: 85%;"></div>
</div>
</div>
<div class="skill-item">
<i class="fab fa-react"></i>
<h3>React</h3>
<div class="skill-bar">
<div class="skill-level" style="width: 80%;"></div>
</div>
</div>
<div class="skill-item">
<i class="fab fa-vuejs"></i>
<h3>Vue.js</h3>
<div class="skill-bar">
<div class="skill-level" style="width: 75%;"></div>
</div>
</div>
<div class="skill-item">
<i class="fab fa-git-alt"></i>
<h3>Git / GitHub</h3>
<div class="skill-bar">
<div class="skill-level" style="width: 88%;"></div>
</div>
</div>
</div>
</div>
</section>
<!-- 项目 -->
<section id="projects" class="projects">
<div class="container">
<h2 class="section-title">我的项目</h2>
<div class="projects-grid">
<div class="project-card">
<img src="https://via.placeholder.com/400x250" alt="项目1">
<h3>电商网站重构</h3>
<p>使用 React 和 Redux 重构了一个大型电商平台,提升了 40% 的页面加载速度和用户交互体验。</p>
<a href="#" class="project-link">查看详情 <i class="fas fa-arrow-right"></i></a>
</div>
<div class="project-card">
<img src="https://via.placeholder.com/400x250" alt="项目2">
<h3>任务管理应用</h3>
<p>一个基于 Vue.js 的任务管理工具,支持拖拽排序、标签分类和团队协作功能。</p>
<a href="#" class="project-link">查看详情 <i class="fas fa-arrow-right"></i></a>
</div>
<div class="project-card">
<img src="https://via.placeholder.com/400x250" alt="项目3">
<h3>个人博客系统</h3>
<p>使用 Next.js 和 Tailwind CSS 搭建的个人博客,支持 Markdown 编写和 SEO 优化。</p>
<a href="#" class="project-link">查看详情 <i class="fas fa-arrow-right"></i></a>
</div>
</div>
</div>
</section>
<!-- 联系方式 -->
<section id="contact" class="contact">
<div class="container">
<h2 class="section-title">联系我</h2>
<p class="contact-intro">有项目想法或合作机会?随时欢迎与我联系!</p>
<div class="contact-links">
<a href="mailto:your.email@example.com" class="contact-link">
<i class="fas fa-envelope"></i> your.email@example.com
</a>
<a href="https://github.com/yourusername" class="contact-link" target="_blank">
<i class="fab fa-github"></i> GitHub
</a>
<a href="https://linkedin.com/in/yourusername" class="contact-link" target="_blank">
<i class="fab fa-linkedin"></i> LinkedIn
</a>
<a href="https://twitter.com/yourusername" class="contact-link" target="_blank">
<i class="fab fa-twitter"></i> Twitter
</a>
</div>
</div>
</section>
<!-- 页脚 -->
<footer class="footer">
<p>© 2025 你的名字. All rights reserved.</p>
</footer>
</body>
</html>
第二步:CSS 样式
我们用 CSS 来美化这个页面,让它看起来专业且富有吸引力。
/* style.css */
:root {
--primary-color: #007bff;
--secondary-color: #343a40;
--text-color: #333;
--light-color: #f8f9fa;
--dark-color: #212529;
--font-family: 'Poppins', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
}
body {
font-family: var(--font-family);
line-height: 1.6;
color: var(--text-color);
background-color: #fff;
}
.container {
max-width: 1100px;
margin: 0 auto;
padding: 0 2rem;
}
样式 */
.section-title {
font-size: 2.5rem;
text-align: center;
margin-bottom: 3rem;
color: var(--secondary-color);
position: relative;
}
.section-title::after {
content: '';
display: block;
width: 60px;
height: 4px;
background: var(--primary-color);
margin: 1rem auto 0;
}
/* 导航栏样式 */
.navbar {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: rgba(255, 255, 255, 0.95);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
z-index: 1000;
transition: all 0.3s ease;
}
.navbar-container {
max-width: 1100px;
margin: 0 auto;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.navbar-logo {
font-size: 1.5rem;
font-weight: 700;
color: var(--primary-color);
text-decoration: none;
}
.navbar-menu {
display: flex;
list-style: none;
}
.nav-link {
color: var(--text-color);
text-decoration: none;
margin-left: 2rem;
font-weight: 600;
transition: color 0.3s ease;
}
.nav-link:hover {
color: var(--primary-color);
}
/* 英雄区样式 */
.hero {
height: 100vh;
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://images.unsplash.com/photo-1557687288-5d7a19e84730?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1740&q=80') no-repeat center center/cover;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
color: #fff;
padding-top: 60px; /* 为固定导航栏留出空间 */
}
.hero-content h1 {
font-size: 3.5rem;
margin-bottom: 1rem;
}
.highlight {
color: var(--primary-color);
}
{
font-size: 1.5rem;
margin-bottom: 2rem;
}
.cta-button {
display: inline-block;
background: var(--primary-color);
color: #fff;
padding: 0.8rem 2rem;
border-radius: 50px;
text-decoration: none;
font-weight: 600;
transition: background 0.3s ease, transform 0.3s ease;
}
.cta-button:hover {
background: #0056b3;
transform: translateY(-3px);
}
/* 关于我样式 */
.about {
padding: 5rem 0;
background: #f8f9fa;
}
.about-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 3rem;
align-items: center;
}
.about-text p {
margin-bottom: 1.5rem;
}
.about-image img {
max-width: 100%;
border-radius: 10px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
/* 技能样式 */
.skills {
padding: 5rem 0;
}
.skills-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
}
.skill-item {
text-align: center;
}
.skill-item i {
font-size: 3rem;
color: var(--primary-color);
margin-bottom: 1rem;
}
.skill-item h3 {
margin-bottom: 0.5rem;
}
.skill-bar {
background: #e0e0e0;
height: 10px;
border-radius: 5px;
overflow: hidden;
}
.skill-level {
height: 100%;
background: var(--primary-color);
border-radius: 5px;
transition: width 1.5s ease-in-out;
}
/* 项目样式 */
.projects {
padding: 5rem 0;
background: #f8f9fa;
}
.projects-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
}
.project-card {
background: #fff;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.project-card:hover {
transform: translateY(-10px);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}
.project-card img {
width: 100%;
height: 200px;
object-fit: cover;
}
.project-card-content {
padding: 1.5rem;
}
.project-card-content h3 {
margin-bottom: 0.5rem;
color: var(--secondary-color);
}
.project-link {
display: inline-block;
margin-top: 1rem;
color: var(--primary-color);
text-decoration: none;
font-weight: 600;
transition: color 0.3s ease;
}
.project-link:hover {
color: #0056b3;
}
/* 联系方式样式 */
.contact {
padding: 5rem 0;
text-align: center;
}
.contact-intro {
font-size: 1.2rem;
max-width: 600px;
margin: 0 auto 2rem;
color: #666;
}
.contact-links {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 1.5rem;
}
.contact-link {
display: flex;
align-items: center;
color: var(--secondary-color);
text-decoration: none;
font-size: 1.1rem;
transition: color 0.3s ease;
}
.contact-link:hover {
color: var(--primary-color);
}
.contact-link i {
margin-right: 0.5rem;
}
/* 页脚样式 */
.footer {
background: var(--secondary-color);
color: #fff;
text-align: center;
padding: 1.5rem 0;
}
/* 响应式设计 */
@media (max-width: 768px) {
.navbar-menu {
display: none; /* 可以用 JS 替换为汉堡菜单 */
}
.hero-content h1 {
font-size: 2.5rem;
}
.subtitle {
font-size: 1.2rem;
}
.about-content,
.skills-grid,
.projects-grid {
grid-template-columns: 1fr;
}
}
第三步:增强功能 (可选)
为了让你的主页更上一层楼,可以添加一些 JavaScript 功能。

(图片来源网络,侵删)
打字机效果
在 hero 区,<span id="typed-text">前端开发者</span> 这段文字可以动态变化。
// 在 HTML 的 <body> 结束标签前添加
<script>
document.addEventListener('DOMContentLoaded', function() {
const texts = ['前端开发者', 'UI/UX 爱好者', '问题解决者'];
const textElement = document.getElementById('typed-text');
let textIndex = 0;
let charIndex = 0;
let isDeleting = false;
function type() {
const currentText = texts[textIndex];
if (isDeleting) {
textElement.textContent = currentText.substring(0, charIndex - 1);
charIndex--;
} else {
textElement.textContent = currentText.substring(0, charIndex + 1);
charIndex++;
}
let typeSpeed = isDeleting ? 50 : 100;
if (!isDeleting && charIndex === currentText.length) {
typeSpeed = 2000; // 停留时间
isDeleting = true;
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
textIndex = (textIndex + 1) % texts.length;
typeSpeed = 500; // 新词开始前的延迟
}
setTimeout(type, typeSpeed);
}
type();
});
</script>
滚动时导航栏高亮
当用户滚动到某个部分时,对应的导航链接应该高亮显示。
// 在上面的 <script> 标签内添加
const sections = document.querySelectorAll('section');
const navLinks = document.querySelectorAll('.nav-link');
window.addEventListener('scroll', () => {
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (pageYOffset >= sectionTop - 200) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href').substring(1) === current) {
link.classList.add('active');
}
});
});
然后在 CSS 中为 .active 类添加样式:
.nav-link.active {
color: var(--primary-color);
}
如何使用
- 创建文件: 创建三个文件:
index.html,style.css, 和一个script.js文件(或者把 JS 直接放在 HTML 的<script>标签里)。 - 复制代码: 将上面的 HTML 和 CSS 代码分别复制到对应的文件中。
- 个性化修改:
- 将所有的
你的名字、your.email@example.com、yourusername等占位符替换成你自己的信息。 - 更换
hero区的背景图片 (url('...')) 和关于我部分的个人照片 (src="...")。 - 修改技能条、项目描述等内容,使其与你的实际情况相符。
- 将所有的
- 部署: 你可以将这些文件上传到任何支持静态网站的托管服务上,如 GitHub Pages, Netlify, Vercel 等,就可以获得一个公开的个人主页链接了。
这个设计为你提供了一个坚实的基础,你可以在此基础上自由地发挥创意,添加更多功能,如深色模式、动画效果等,打造出独一无二的个人品牌形象。

(图片来源网络,侵删)
