将所学知识应用到实际项目中
创建一个现代化的响应式企业官网首页,包含导航栏、英雄区域、产品展示、团队介绍、联系表单等模块。
/* 文件结构 */
/index.html
/css
/base
- reset.css
- typography.css
/components
- header.css
- hero.css
- features.css
- team.css
- contact.css
- footer.css
/utilities
- colors.css
- spacing.css
- main.css
/js
- theme-toggle.js/* 响应式导航 */
.nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
}
.nav__menu {
display: flex;
gap: 20px;
}
@media screen and (max-width: 768px) {
.nav__menu {
display: none;
}
.nav__toggle {
display: block;
}
}
/* 响应式网格 */
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 30px;
padding: 60px 20px;
}创建一个数据仪表盘,包含各种图表、数据卡片、筛选器等功能,支持响应式布局。
/* 文件结构 */
/index.html
/css
/base
- reset.css
/components
- sidebar.css
- header.css
- card.css
- chart.css
- filter.css
/utilities
- variables.css
- responsive.css
- main.css
/js
- chart.js
- filter.js/* 仪表盘布局 */
.dashboard {
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: 60px 1fr;
height: 100vh;
}
.dashboard__sidebar {
grid-row: 1 / -1;
background: #2c3e50;
color: white;
}
.dashboard__content {
padding: 20px;
overflow-y: auto;
}
/* 卡片容器查询 */
.card {
container-type: inline-size;
background: white;
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
@container (min-width: 400px) {
.card__content {
display: flex;
justify-content: space-between;
align-items: center;
}
}创建一个创意个人作品集网站,展示个人项目、技能和联系方式,突出个人风格。
/* 文件结构 */
/index.html
/css
/base
- reset.css
/components
- hero.css
- projects.css
- skills.css
- about.css
- contact.css
/utilities
- animations.css
- colors.css
- main.css
/js
- scroll-animations.js/* 创意英雄区域 */
.hero {
position: relative;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
overflow: hidden;
}
.hero::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
background-size: 50px 50px;
animation: grid-move 20s linear infinite;
}
@keyframes grid-move {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(50px, 50px);
}
}
/* 项目卡片 */
.project-card {
position: relative;
overflow: hidden;
border-radius: 12px;
transition: all 0.3s ease;
}
.project-card:hover {
transform: translateY(-10px);
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.project-card__overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
opacity: 0;
transition: opacity 0.3s ease;
}
.project-card:hover .project-card__overlay {
opacity: 1;
}