feat: Add CSS layout exercises and corresponding HTML files

- Created multiple exercises under the CSS layout section, including:
  - Final page layout with CSS styles and HTML structure.
  - Display and flow concepts with examples of block, inline, and none display types.
  - Selectors and pseudo-classes with practical examples.
  - Overflow and sizing handling in CSS.
  - Grid layout basics for two-dimensional layouts.
  - Fixed and sticky positioning examples.
  - Centering techniques for common layout scenarios.

- Added README files for each exercise to outline objectives and file structures.
- Updated main README to include new sections and usage instructions.
This commit is contained in:
chali
2026-03-09 14:16:22 +08:00
commit 4495ae0e28
85 changed files with 2566 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
# 练习 3Flex 布局
## 目标
学会用 Flex 做横向排列、间距和居中。
## 你要练什么
- `display: flex`
- `justify-content`
- `align-items`
- `gap`
- `flex: 1`
## 任务
请完成一个三列学习面板,要求:
- 3 个卡片横向排列
- 卡片之间有统一间距
- 每个卡片宽度尽量均分
- 标题和按钮排版清晰
- 整个区域居中显示
## 文件
- [starter.html](/Volumes/Macintosh HD 1/home/front-end-example/02-css-layout/03-flex-layout/starter.html)
- [starter.css](/Volumes/Macintosh HD 1/home/front-end-example/02-css-layout/03-flex-layout/starter.css)
- [answer.html](/Volumes/Macintosh HD 1/home/front-end-example/02-css-layout/03-flex-layout/answer.html)
- [answer.css](/Volumes/Macintosh HD 1/home/front-end-example/02-css-layout/03-flex-layout/answer.css)

View File

@@ -0,0 +1,31 @@
body {
margin: 0;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #f8fafc;
font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
.panel {
width: min(1100px, calc(100% - 48px));
display: flex;
gap: 20px;
}
.item {
flex: 1;
padding: 24px;
border-radius: 18px;
background: #ffffff;
border: 1px solid #e2e8f0;
}
a {
display: inline-block;
margin-top: 16px;
color: #0f766e;
text-decoration: none;
font-weight: 700;
}

View File

@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Flex 布局</title>
<link rel="stylesheet" href="./answer.css" />
</head>
<body>
<section class="panel">
<article class="item">
<h2>HTML</h2>
<p>学习页面结构和标签。</p>
<a href="#">开始</a>
</article>
<article class="item">
<h2>CSS</h2>
<p>学习布局、样式和视觉表现。</p>
<a href="#">开始</a>
</article>
<article class="item">
<h2>JavaScript</h2>
<p>学习交互、逻辑和数据处理。</p>
<a href="#">开始</a>
</article>
</section>
</body>
</html>

View File

@@ -0,0 +1,11 @@
body {
}
.panel {
}
.item {
}
a {
}

View File

@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Flex 布局</title>
<link rel="stylesheet" href="./starter.css" />
</head>
<body>
<section class="panel">
<article class="item">
<h2>HTML</h2>
<p>学习页面结构和标签。</p>
<a href="#">开始</a>
</article>
<article class="item">
<h2>CSS</h2>
<p>学习布局、样式和视觉表现。</p>
<a href="#">开始</a>
</article>
<article class="item">
<h2>JavaScript</h2>
<p>学习交互、逻辑和数据处理。</p>
<a href="#">开始</a>
</article>
</section>
</body>
</html>