最终效果预览

这是一个我们即将创建的网页的截图,您可以看到它的布局和设计风格。

html网页设计个人简介代码
(图片来源网络,侵删)

代码结构

我们将创建三个文件:

  1. index.html: 网页的结构和内容。
  2. style.css: 网页的样式(颜色、字体、布局等)。
  3. script.js: 一些简单的交互效果(如平滑滚动)。

您可以将这三个文件保存在同一个文件夹中,然后用浏览器打开 index.html 文件即可查看效果。


HTML 代码 (index.html)

这是网页的骨架,包含了所有文本内容和结构。

<!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">
    <!-- 引入一个流行的图标库 Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body>
    <!-- 导航栏 -->
    <header>
        <nav>
            <a href="#home" class="nav-link">首页</a>
            <a href="#about" class="nav-link">关于我</a>
            <a href="#skills" class="nav-link">技能</a>
            <a href="#projects" class="nav-link">项目</a>
            <a href="#contact" class="nav-link">联系我</a>
        </nav>
    </header>
    <main>
        <!-- 首页/英雄区域 -->
        <section id="home" class="hero">
            <div class="hero-content">
                <img src="https://via.placeholder.com/150" alt="我的头像" class="profile-img">
                <h1>你好,我是张三</h1>
                <p class="subtitle">一名充满激情的前端开发工程师</p>
                <p>我专注于创建美观、快速且用户友好的网站和网络应用。</p>
                <a href="#contact" class="cta-button">联系我</a>
            </div>
        </section>
        <!-- 关于我 -->
        <section id="about" class="about">
            <h2>关于我</h2>
            <div class="about-content">
                <div class="about-text">
                    <p>
                        我是一名拥有3年经验的前端开发工程师,毕业于XX大学计算机科学专业,我热爱编程,享受将复杂的问题转化为简洁、优雅的解决方案的过程。
                    </p>
                    <p>
                        在我的职业生涯中,我参与了多个大型项目的开发,从电商网站到企业管理系统,积累了丰富的实战经验,我相信持续学习是保持竞争力的关键,因此我总是关注最新的前端技术和发展趋势。
                    </p>
                </div>
                <div class="about-details">
                    <p><i class="fas fa-user"></i> <strong>姓名:</strong> 张三</p>
                    <p><i class="fas fa-briefcase"></i> <strong>职业:</strong> 前端开发工程师</p>
                    <p><i class="fas fa-graduation-cap"></i> <strong>学历:</strong> 本科</p>
                    <p><i class="fas fa-map-marker-alt"></i> <strong>地点:</strong> 中国上海</p>
                    <p><i class="fas fa-envelope"></i> <strong>邮箱:</strong> zhangsan@example.com</p>
                </div>
            </div>
        </section>
        <!-- 技能 -->
        <section id="skills" class="skills">
            <h2>我的技能</h2>
            <div class="skills-container">
                <div class="skill-category">
                    <h3>前端技术</h3>
                    <div class="skill-item">
                        <span>HTML5 / CSS3</span>
                        <div class="skill-bar">
                            <div class="skill-level" style="width: 95%;"></div>
                        </div>
                    </div>
                    <div class="skill-item">
                        <span>JavaScript (ES6+)</span>
                        <div class="skill-bar">
                            <div class="skill-level" style="width: 90%;"></div>
                        </div>
                    </div>
                    <div class="skill-item">
                        <span>React / Vue.js</span>
                        <div class="skill-bar">
                            <div class="skill-level" style="width: 85%;"></div>
                        </div>
                    </div>
                </div>
                <div class="skill-category">
                    <h3>工具与其他</h3>
                    <div class="skill-item">
                        <span>Git / GitHub</span>
                        <div class="skill-bar">
                            <div class="skill-level" style="width: 88%;"></div>
                        </div>
                    </div>
                    <div class="skill-item">
                        <span>Webpack / Vite</span>
                        <div class="skill-bar">
                            <div class="skill-level" style="width: 80%;"></div>
                        </div>
                    </div>
                    <div class="skill-item">
                        <span>UI/UX 设计</span>
                        <div class="skill-bar">
                            <div class="skill-level" style="width: 75%;"></div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- 项目 -->
        <section id="projects" class="projects">
            <h2>我的项目</h2>
            <div class="projects-grid">
                <div class="project-card">
                    <img src="https://via.placeholder.com/400x250" alt="项目1截图">
                    <h3>在线商城网站</h3>
                    <p>使用 React 和 Node.js 构建的全栈电商应用,支持用户注册、商品浏览、购物车和支付功能。</p>
                    <div class="project-links">
                        <a href="#"><i class="fab fa-github"></i> 源码</a>
                        <a href="#"><i class="fas fa-external-link-alt"></i> 预览</a>
                    </div>
                </div>
                <div class="project-card">
                    <img src="https://via.placeholder.com/400x250" alt="项目2截图">
                    <h3>任务管理应用</h3>
                    <p>一个基于 Vue.js 的单页应用,帮助用户高效地管理日常任务,支持拖拽排序和标签分类。</p>
                    <div class="project-links">
                        <a href="#"><i class="fab fa-github"></i> 源码</a>
                        <a href="#"><i class="fas fa-external-link-alt"></i> 预览</a>
                    </div>
                </div>
                <div class="project-card">
                    <img src="https://via.placeholder.com/400x250" alt="项目3截图">
                    <h3>个人博客系统</h3>
                    <p>使用 Jekyll 和 Bootstrap 搭建的个人博客,专注于技术分享和读书笔记。</p>
                    <div class="project-links">
                        <a href="#"><i class="fab fa-github"></i> 源码</a>
                        <a href="#"><i class="fas fa-external-link-alt"></i> 预览</a>
                    </div>
                </div>
            </div>
        </section>
        <!-- 联系我 -->
        <section id="contact" class="contact">
            <h2>联系我</h2>
            <p>如果您对我的工作感兴趣,或者有任何问题,欢迎随时与我联系!</p>
            <div class="contact-info">
                <a href="mailto:zhangsan@example.com"><i class="fas fa-envelope"></i> zhangsan@example.com</a>
                <a href="tel:+8613800138000"><i class="fas fa-phone"></i> +86 138 0013 8000</a>
                <a href="https://github.com/zhangsan" target="_blank"><i class="fab fa-github"></i> GitHub</a>
                <a href="https://linkedin.com/in/zhangsan" target="_blank"><i class="fab fa-linkedin"></i> LinkedIn</a>
            </div>
        </section>
    </main>
    <!-- 页脚 -->
    <footer>
        <p>&copy; 2025 张三. All rights reserved.</p>
    </footer>
    <!-- 引入 JavaScript 文件 -->
    <script src="script.js"></script>
</body>
</html>

CSS 代码 (style.css)

这是网页的“化妆师”,负责美化页面,代码中包含了详细的注释,解释了每个部分的作用。

html网页设计个人简介代码
(图片来源网络,侵删)
/* --- 全局样式和变量 --- */
:root {
    --primary-color: #007bff;
    --secondary-color: #343a40;
    --text-color: #333;
    --light-bg-color: #f8f9fa;
    --white-color: #ffffff;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --section-padding: 80px 20px;
}
* {
    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: var(--white-color);
}
h1, h2, h3 {
    font-weight: 600;
    margin-bottom: 1rem;
}
a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.3s ease;
}
a:hover {
    color: #0056b3;
}
p {
    margin-bottom: 1rem;
}
img {
    max-width: 100%;
    height: auto;
    display: block;
}
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}
section {
    padding: var(--section-padding);
    text-align: center;
}
section h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--secondary-color);
}
/* --- 导航栏 --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.95); /* 半透明背景 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: background-color 0.3s ease;
}
header nav {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 2rem;
}
.nav-link {
    color: var(--text-color);
    margin: 0 1.5rem;
    font-weight: 500;
    transition: color 0.3s ease;
}
.nav-link:hover, .nav-link.active {
    color: var(--primary-color);
}
/* --- 首页/英雄区域 --- */
.hero {
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('https://images.unsplash.com/photo-1555066931-4365d14bab8c?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1740&q=80') no-repeat center center/cover;
    color: var(--white-color);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.hero-content {
    max-width: 800px;
}
.profile-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 5px solid var(--white-color);
    margin-bottom: 2rem;
}
.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}
.hero .subtitle {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 300;
}
.cta-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--white-color);
    padding: 12px 30px;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.3s ease;
}
.cta-button:hover {
    background-color: #0056b3;
    transform: translateY(-3px);
}
/* --- 关于我 --- */
.about {
    background-color: var(--light-bg-color);
}
.about-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    text-align: left;
}
.about-text {
    flex: 1 1 300px;
}
.about-details {
    flex: 1 1 250px;
    background-color: var(--white-color);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}
.about-details p {
    margin-bottom: 1rem;
    font-size: 1rem;
}
.about-details i {
    color: var(--primary-color);
    margin-right: 10px;
    width: 20px;
}
/* --- 技能 --- */
.skills-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 2rem;
}
.skill-category {
    flex: 1 1 300px;
    background-color: var(--white-color);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    text-align: left;
}
.skill-category h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--secondary-color);
}
.skill-item {
    margin-bottom: 1.5rem;
}
.skill-item span {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.skill-bar {
    background-color: #e9ecef;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}
.skill-level {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    width: 0; /* 初始为0,用于动画 */
    animation: fillBar 2s ease-out forwards;
}
@keyframes fillBar {
    to {
        width: var(--level); /* 这个变量会在HTML中设置 */
    }
}
/* --- 项目 --- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}
.project-card {
    background-color: var(--white-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.project-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}
.project-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}
.project-card-content {
    padding: 1.5rem;
}
.project-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--secondary-color);
}
.project-links {
    margin-top: 1rem;
}
.project-links a {
    margin-right: 1rem;
    font-size: 1.2rem;
}
/* --- 联系我 --- */
.contact-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
}
.contact-info a {
    display: flex;
    align-items: center;
    background-color: var(--light-bg-color);
    padding: 15px 25px;
    border-radius: 50px;
    font-size: 1.1rem;
    transition: background-color 0.3s ease;
}
.contact-info a:hover {
    background-color: var(--primary-color);
    color: var(--white-color);
}
.contact-info i {
    margin-right: 10px;
    font-size: 1.3rem;
}
/* --- 页脚 --- */
footer {
    background-color: var(--secondary-color);
    color: var(--white-color);
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
}
/* --- 响应式设计 --- */
@media (max-width: 768px) {
    header nav {
        flex-direction: column;
        padding: 1rem;
    }
    .nav-link {
        margin: 0.5rem 0;
    }
    .hero h1 {
        font-size: 2.5rem;
    }
    .hero .subtitle {
        font-size: 1.2rem;
    }
    section {
        padding: 60px 15px;
    }
    .about-content, .skills-container {
        flex-direction: column;
    }
    .contact-info {
        flex-direction: column;
        align-items: center;
    }
}

JavaScript 代码 (script.js)

这是一个简单的脚本,用于实现导航栏高亮当前所在区域的交互效果。

document.addEventListener('DOMContentLoaded', () => {
    // 获取所有导航链接和所有区域
    const navLinks = document.querySelectorAll('.nav-link');
    const sections = document.querySelectorAll('section');
    // 函数用于更新活动链接
    function updateActiveLink() {
        let current = '';
        sections.forEach(section => {
            const sectionTop = section.offsetTop;
            const sectionHeight = section.clientHeight;
            if (scrollY >= (sectionTop - 200)) {
                current = section.getAttribute('id');
            }
        });
        navLinks.forEach(link => {
            link.classList.remove('active');
            if (link.getAttribute('href').slice(1) === current) {
                link.classList.add('active');
            }
        });
    }
    // 滚动事件监听器
    window.addEventListener('scroll', updateActiveLink);
    // 初始加载时也调用一次
    updateActiveLink();
});

如何使用和自定义

  1. 创建文件: 创建一个文件夹,在里面新建 index.html, style.css, 和 script.js 三个文件,并将上面的代码分别复制粘贴进去。
  2. 替换个人信息:
    • 头像: 将 index.html<img src="https://via.placeholder.com/150" ...>src 属性替换为你自己的头像图片链接或本地路径。
    • 背景图: style.css.hero 类的 background-image URL 替换为你喜欢的背景图。
    • : 修改所有 <h1>, <p>, <h3> 等标签内的文字,填入你自己的信息。
    • 联系方式: 修改 contact 部分的邮箱、电话、社交媒体链接。
    • 项目信息: 修改 projects 部分的图片、标题、描述和链接。
  3. 调整技能水平: 在 index.html 的技能部分,找到 style="width: ...%;",修改百分比值来反映你的真实技能水平。
  4. 预览: 直接用浏览器打开 index.html 文件,你就可以看到你的个人简介网页了。

这个设计是一个很好的起点,你可以通过修改 CSS 中的颜色、字体等变量来快速改变整个网页的风格,让它更符合你的个人品味。