HTML实战:响应式个人资料页面
我将创建一个现代化的响应式个人资料页面,展示HTML在实际应用中的强大功能。这个页面将包含多个实战元素:导航栏、个人简介、技能展示、作品集和联系表单。
设计思路
-
使用Flexbox和Grid布局实现响应式设计
-
添加CSS过渡效果增强交互体验
-
实现深色/浅色模式切换功能
-
创建悬停动画效果提升视觉体验
-
确保所有元素在不同设备上完美显示
下面是完整的HTML代码实现:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML实战 - 响应式个人资料页面</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
:root {
--primary: #4361ee;
--secondary: #3f37c9;
--accent: #4895ef;
--light: #f8f9fa;
--dark: #212529;
--text: #333;
--bg: #ffffff;
--card-bg: #f8f9fa;
--shadow: rgba(0, 0, 0, 0.1);
--transition: all 0.3s ease;
}
.dark-mode {
--primary: #4895ef;
--secondary: #4361ee;
--accent: #3f37c9;
--light: #343a40;
--dark: #f8f9fa;
--text: #f8f9fa;
--bg: #121212;
--card-bg: #1e1e1e;
--shadow: rgba(0, 0, 0, 0.3);
}
body {
background-color: var(--bg);
color: var(--text);
line-height: 1.6;
transition: var(--transition);
}
.container {
width: 90%;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
/* 头部样式 */
header {
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
padding: 1rem 0;
position: sticky;
top: 0;
z-index: 100;
box-shadow: 0 2px 10px var(--shadow);
}
.header-container {
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-size: 1.8rem;
font-weight: 700;
display: flex;
align-items: center;
}
.logo i {
margin-right: 10px;
color: var(--accent);
}
nav ul {
display: flex;
list-style: none;
}
nav ul li {
margin-left: 1.5rem;
}
nav ul li a {
color: white;
text-decoration: none;
font-weight: 500;
padding: 8px 12px;
border-radius: 4px;
transition: var(--transition);
}
nav ul li a:hover {
background: rgba(255, 255, 255, 0.1);
}
.theme-toggle {
background: none;
border: none;
color: white;
font-size: 1.2rem;
cursor: pointer;
margin-left: 20px;
transition: var(--transition);
}
/* 英雄区域 */
.hero {
padding: 100px 0;
text-align: center;
background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('https://images.unsplash.com/photo-1499951360447-b19be8fe80f5?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80') center/cover no-repeat;
color: white;
}
.hero h1 {
font-size: 3.5rem;
margin-bottom: 1rem;
animation: fadeInDown 1s ease;
}
.hero p {
font-size: 1.5rem;
max-width: 700px;
margin: 0 auto 2rem;
animation: fadeInUp 1s ease;
}
.btn {
display: inline-block;
background: var(--accent);
color: white;
padding: 12px 30px;
border-radius: 50px;
text-decoration: none;
font-weight: 600;
transition: var(--transition);
border: 2px solid var(--accent);
animation: fadeIn 1.5s ease;
}
.btn:hover {
background: transparent;
transform: translateY(-3px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
/* 关于区域 */
.section {
padding: 80px 0;
}
.section-title {
text-align: center;
margin-bottom: 60px;
}
.section-title h2 {
font-size: 2.5rem;
color: var(--primary);
position: relative;
display: inline-block;
padding-bottom: 15px;
}
.section-title h2::after {
content: '';
position: absolute;
bottom: 0;
l