习题解答 | 金阳光社区网
这道题要做一个完整的注册页面。观察效果图,页面由三部分组成:
关键实现要点:
*完整代码如下(register.html):
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>个人注册 - 金阳光社区网</title>
<style>
/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "微软雅黑", sans-serif; font-size: 14px; background: #f0f0f0; color: #333; }
a { text-decoration: none; color: inherit; }
ul, li { list-style: none; }
/* ===== 顶部红条 ===== */
.top-bar {
width: 100%; height: 8px;
background: #d10909;
}
/* ===== 登录注册小字 ===== */
.header-top {
width: 1200px; margin: 0 auto;
height: 30px; line-height: 30px;
text-align: right; font-size: 12px; color: #666;
}
.header-top a { margin-left: 10px; color: #666; }
.header-top a:hover { color: #d10909; }
/* ===== Logo 区域 ===== */
.header-logo {
width: 100%;
background: #3a3a3a url('') center;
/* 使用渐变模拟深色纹理背景 */
background: linear-gradient(135deg, #2a2a2a 0%, #4a4a4a 50%, #2a2a2a 100%);
height: 143px;
margin-top: 5px;
}
.header-logo .inner {
width: 1200px; margin: 0 auto;
display: flex; align-items: center;
height: 100%; justify-content: space-between;
}
.logo-title {
font-size: 42px; font-weight: bold;
color: #fff; letter-spacing: 4px;
text-shadow: 2px 2px 6px rgba(0,0,0,0.5);
}
.logo-slogan {
font-size: 22px; color: #e0e0e0;
letter-spacing: 2px;
}
/* ===== 搜索栏 ===== */
.search-bar {
width: 1200px; margin: 0 auto;
display: flex; justify-content: flex-end;
align-items: center; padding: 8px 0;
}
.search-bar input[type="text"] {
width: 220px; height: 28px;
border: 1px solid #ccc; padding: 0 8px;
font-size: 13px; outline: none;
}
.search-bar button {
height: 28px; padding: 0 12px;
background: #555; color: #fff;
border: none; cursor: pointer; font-size: 13px;
}
.search-bar button:hover { background: #d10909; }
/* ===== 导航栏 ===== */
.nav-bar {
width: 100%; background: #444;
border-top: 2px solid #d10909;
}
.nav-bar ul {
width: 1200px; margin: 0 auto;
display: flex;
}
.nav-bar ul li a {
display: block; padding: 0 20px;
height: 42px; line-height: 42px;
color: #fff; font-size: 14px;
}
.nav-bar ul li a:hover,
.nav-bar ul li.active a { background: #d10909; }
/* ===== 内容区域 ===== */
.content {
width: 1200px; margin: 30px auto 0;
background: #fff;
border: 1px solid #e0e0e0;
min-height: 500px;
}
/* ===== 注册头部 ===== */
.reg-header {
padding: 15px 20px;
border-bottom: 1px solid #eee;
display: flex; justify-content: space-between;
align-items: center;
}
.reg-header .reg-title { font-size: 16px; font-weight: bold; color: #333; }
.reg-header .login-link { font-size: 13px; color: #888; }
.reg-header .login-link a { color: #d10909; }
/* ===== 注册表单 ===== */
.reg-form-wrap {
padding: 30px 0;
display: flex; justify-content: center;
}
.reg-form {
width: 500px;
}
.reg-form h3 {
text-align: center; font-size: 18px;
color: #333; margin-bottom: 25px;
letter-spacing: 2px;
}
/* 每一行表单项 */
.form-row {
display: flex; align-items: center;
margin-bottom: 16px;
}
.form-label {
width: 90px; text-align: right;
font-size: 14px; color: #555;
padding-right: 10px; flex-shrink: 0;
}
.form-label.required::before {
content: "* "; color: #d10909; font-weight: bold;
}
.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="tel"],
.form-row input[type="email"] {
width: 280px; height: 32px;
border: 1px solid #ccc; padding: 0 8px;
font-size: 13px; outline: none;
color: #333;
}
.form-row input:focus { border-color: #d10909; }
.form-row input::placeholder { color: #bbb; }
/* 所在地区:三个下拉框 */
.area-selects select {
height: 32px; border: 1px solid #ccc;
padding: 0 4px; font-size: 13px;
outline: none; cursor: pointer;
margin-right: 4px;
}
.area-selects span { font-size: 13px; color: #555; margin-right: 6px; }
/* 验证码行 */
.captcha-row { display: flex; align-items: center; }
.captcha-row input {
width: 130px; height: 32px;
border: 1px solid #ccc; padding: 0 8px;
font-size: 13px; outline: none; margin-right: 8px;
}
.captcha-img {
display: inline-block;
width: 80px; height: 32px;
background: linear-gradient(135deg, #ddd 0%, #f5f5f5 100%);
border: 1px solid #ccc;
line-height: 32px; text-align: center;
font-size: 16px; font-style: italic;
letter-spacing: 4px; color: #555;
font-family: "Courier New", monospace;
font-weight: bold;
}
.captcha-link { font-size: 12px; color: #888; margin-left: 8px; }
.captcha-link a { color: #5b9bd5; }
.captcha-link a:hover { color: #d10909; }
/* 提交按钮 */
.submit-row { text-align: center; margin-top: 24px; }
.submit-btn {
width: 160px; height: 40px;
background: #444; color: #fff;
border: none; font-size: 16px;
cursor: pointer; letter-spacing: 2px;
border-radius: 2px;
}
.submit-btn:hover { background: #d10909; }
/* ===== 页脚 ===== */
.footer-wrap {
width: 100%; background: #3a3a3a;
margin-top: 40px; padding: 30px 0 25px;
}
.footer-inner {
width: 1200px; margin: 0 auto;
text-align: center; color: #ccc;
}
.footer-inner p { font-size: 12px; line-height: 26px; }
.footer-inner a { color: #ccc; }
.footer-inner a:hover { color: #fff; }
</style>
</head>
<body>
<!-- 顶部红条 -->
<div class="top-bar"></div>
<!-- 登录注册小字 -->
<div class="header-top">
<a href="#">登录</a> | <a href="#">注册</a>
</div>
<!-- Logo 区域 -->
<div class="header-logo">
<div class="inner">
<div class="logo-title">金阳光社区网</div>
<div class="logo-slogan">推进社区发展 服务百姓生活</div>
</div>
</div>
<!-- 搜索栏 -->
<div class="search-bar">
<input type="text" placeholder="">
<button>站内搜索</button>
</div>
<!-- 导航栏 -->
<div class="nav-bar">
<ul>
<li><a href="#">网站首页</a></li>
<li><a href="#">生活指南</a></li>
<li><a href="#">热点关注</a></li>
<li><a href="#">政策解读</a></li>
<li><a href="#">公益捐赠</a></li>
<li><a href="#">在线调查</a></li>
<li><a href="#">我要留言</a></li>
<li class="active"><a href="#">注册加入</a></li>
<li><a href="#">联系我们</a></li>
</ul>
</div>
<!-- 注册内容区域 -->
<div class="content">
<div class="reg-header">
<span class="reg-title">立即注册</span>
<span class="login-link">已有账户,<a href="#">直接登录</a></span>
</div>
<div class="reg-form-wrap">
<div class="reg-form">
<h3>个人注册</h3>
<form action="#" method="post">
<!-- 登录名称 -->
<div class="form-row">
<label class="form-label required">登录名称:</label>
<input type="text" name="username" maxlength="20">
</div>
<!-- 所在地区 -->
<div class="form-row">
<label class="form-label required">所在地区:</label>
<div class="area-selects">
<select name="province">
<option value="">▼ 省</option>
<option>北京市</option>
<option>上海市</option>
<option>广东省</option>
<option>浙江省</option>
<option>江苏省</option>
</select>
<select name="city">
<option value="">▼ 市</option>
</select>
<select name="district">
<option value="">▼ 县/区</option>
</select>
</div>
</div>
<!-- 姓名 -->
<div class="form-row">
<label class="form-label required">姓名:</label>
<input type="text" name="realname" maxlength="20">
</div>
<!-- 手机号 -->
<div class="form-row">
<label class="form-label required">手机号:</label>
<input type="tel" name="phone" maxlength="11">
</div>
<!-- 邮箱 -->
<div class="form-row">
<label class="form-label">邮箱:</label>
<input type="email" name="email" placeholder="您可以通过邮箱找回密码">
</div>
<!-- 密码 -->
<div class="form-row">
<label class="form-label required">密码:</label>
<input type="password" name="password">
</div>
<!-- 重复密码 -->
<div class="form-row">
<label class="form-label required">重复密码:</label>
<input type="password" name="repassword">
</div>
<!-- 推荐人 -->
<div class="form-row">
<label class="form-label">推荐人:</label>
<input type="text" name="referrer" maxlength="20">
</div>
<!-- 验证码 -->
<div class="form-row">
<label class="form-label required">验证码:</label>
<div class="captcha-row">
<input type="text" name="captcha" maxlength="6">
<span class="captcha-img">3S1833</span>
<span class="captcha-link"><a href="#">看不清?换一张</a></span>
</div>
</div>
<!-- 提交按钮 -->
<div class="submit-row">
<button type="submit" class="submit-btn">立即注册</button>
</div>
</form>
</div>
</div>
</div>
<!-- 页脚 -->
<div class="footer-wrap">
<div class="footer-inner">
<p>社区网(www.shequ.cn)*2020 版权所有 All Rights Reserved.</p>
<p>主办单位名称:社区研究会 网站备案号:京ICP备10006066号
营业执照经营许可证编号:京ICP证160666号
京公网安备:11011402010666号</p>
</div>
</div>
</body>
</html>
📖 参见 12.2 制作社区新闻网首页(全局样式和结构复用)
这道题要做一个在线调查问卷页面。观察效果图:
完整代码如下(survey.html):
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>在线调查 - 金阳光社区网</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "微软雅黑", sans-serif; font-size: 14px; background: #f0f0f0; color: #333; }
a { text-decoration: none; color: inherit; }
ul, li { list-style: none; }
/* ===== 顶部红条 ===== */
.top-bar { width: 100%; height: 8px; background: #d10909; }
/* ===== 登录注册小字 ===== */
.header-top {
width: 1200px; margin: 0 auto;
height: 30px; line-height: 30px;
text-align: right; font-size: 12px; color: #666;
}
.header-top a { margin-left: 10px; color: #666; }
.header-top a:hover { color: #d10909; }
/* ===== Logo 区域 ===== */
.header-logo {
width: 100%;
background: linear-gradient(135deg, #2a2a2a 0%, #4a4a4a 50%, #2a2a2a 100%);
height: 143px; margin-top: 5px;
}
.header-logo .inner {
width: 1200px; margin: 0 auto;
display: flex; align-items: center;
height: 100%; justify-content: space-between;
}
.logo-title { font-size: 42px; font-weight: bold; color: #fff; letter-spacing: 4px; }
.logo-slogan { font-size: 22px; color: #e0e0e0; letter-spacing: 2px; }
/* ===== 搜索栏 ===== */
.search-bar {
width: 1200px; margin: 0 auto;
display: flex; justify-content: flex-end;
align-items: center; padding: 8px 0;
}
.search-bar input[type="text"] {
width: 220px; height: 28px;
border: 1px solid #ccc; padding: 0 8px; font-size: 13px; outline: none;
}
.search-bar button {
height: 28px; padding: 0 12px;
background: #555; color: #fff; border: none; cursor: pointer; font-size: 13px;
}
.search-bar button:hover { background: #d10909; }
/* ===== 导航栏 ===== */
.nav-bar { width: 100%; background: #444; border-top: 2px solid #d10909; }
.nav-bar ul { width: 1200px; margin: 0 auto; display: flex; }
.nav-bar ul li a {
display: block; padding: 0 20px;
height: 42px; line-height: 42px;
color: #fff; font-size: 14px;
}
.nav-bar ul li a:hover,
.nav-bar ul li.active a { background: #d10909; }
/* ===== 内容区域:左右布局 ===== */
.content {
width: 1200px; margin: 30px auto;
display: flex; gap: 20px; align-items: flex-start;
}
/* ===== 左侧导航 ===== */
.left-nav {
width: 200px; flex-shrink: 0;
border: 1px solid #e0e0e0; background: #fff;
}
.left-nav .nav-cat {
display: flex; align-items: center;
padding: 10px 15px; font-size: 15px;
font-weight: bold; color: #333;
border-bottom: 1px solid #eee;
}
.left-nav .nav-cat::before {
content: "●"; color: #d10909;
margin-right: 8px; font-size: 10px;
}
.left-nav ul { padding: 8px 0; }
.left-nav ul li a {
display: block; padding: 8px 15px 8px 30px;
color: #555; font-size: 14px;
}
.left-nav ul li a:hover { color: #d10909; background: #fafafa; }
.left-nav ul li.active a {
color: #fff; background: #d10909;
}
/* ===== 右侧内容 ===== */
.right-content { flex: 1; min-width: 0; background: #fff; border: 1px solid #e0e0e0; }
/* 面包屑 */
.breadcrumb {
padding: 8px 15px;
font-size: 12px; color: #999;
text-align: right;
border-bottom: 1px solid #eee;
}
.breadcrumb a { color: #999; }
.breadcrumb a:hover { color: #d10909; }
/* 分类标题 */
.cat-header {
padding: 12px 15px;
display: flex; align-items: center;
border-bottom: 1px solid #eee;
}
.cat-header::before {
content: "●"; color: #d10909;
margin-right: 8px; font-size: 10px;
}
.cat-header span { font-size: 15px; font-weight: bold; color: #333; }
/* 调查区域 */
.survey-area { padding: 20px 30px 30px; }
.survey-title {
font-size: 20px; font-weight: bold;
text-align: center; color: #333; margin-bottom: 5px;
}
.survey-date {
text-align: center; color: #999; font-size: 12px; margin-bottom: 25px;
}
/* 问题行 */
.q-row { margin-bottom: 18px; }
.q-label { font-size: 14px; color: #333; margin-bottom: 8px; font-weight: 500; }
.q-label span { color: #d10909; }
/* 下拉选择(省市区) */
.area-selects select {
height: 30px; border: 1px solid #ccc;
padding: 0 6px; font-size: 13px; outline: none; cursor: pointer;
margin-right: 4px;
}
/* 单选/多选选项行 */
.options-row { display: flex; flex-wrap: wrap; gap: 6px 0; }
.options-row label {
display: inline-flex; align-items: center;
margin-right: 22px; font-size: 14px; cursor: pointer; color: #444;
}
.options-row label input {
margin-right: 4px; cursor: pointer;
accent-color: #d10909;
}
/* 文本域 */
.survey-textarea {
width: 100%; height: 80px; border: 1px solid #ccc;
padding: 8px; font-size: 13px; resize: vertical;
outline: none; font-family: "微软雅黑", sans-serif;
}
.survey-textarea:focus { border-color: #d10909; }
/* 提交按钮 */
.submit-row { text-align: center; margin-top: 24px; }
.submit-btn {
width: 80px; height: 36px;
background: #555; color: #fff; border: none;
font-size: 15px; cursor: pointer; letter-spacing: 2px; border-radius: 2px;
}
.submit-btn:hover { background: #d10909; }
/* ===== 页脚 ===== */
.footer-wrap { width: 100%; background: #3a3a3a; margin-top: 20px; padding: 30px 0 25px; }
.footer-inner { width: 1200px; margin: 0 auto; text-align: center; color: #ccc; }
.footer-inner p { font-size: 12px; line-height: 26px; }
</style>
</head>
<body>
<div class="top-bar"></div>
<div class="header-top">
<a href="#">登录</a> | <a href="#">注册</a>
</div>
<div class="header-logo">
<div class="inner">
<div class="logo-title">金阳光社区网</div>
<div class="logo-slogan">推进社区发展 服务百姓生活</div>
</div>
</div>
<div class="search-bar">
<input type="text" placeholder="">
<button>站内搜索</button>
</div>
<div class="nav-bar">
<ul>
<li><a href="#">网站首页</a></li>
<li><a href="#">生活指南</a></li>
<li><a href="#">热点关注</a></li>
<li><a href="#">政策解读</a></li>
<li><a href="#">公益捐赠</a></li>
<li class="active"><a href="#">在线调查</a></li>
<li><a href="#">我要留言</a></li>
<li><a href="#">注册加入</a></li>
<li><a href="#">联系我们</a></li>
</ul>
</div>
<div class="content">
<!-- 左侧导航 -->
<div class="left-nav">
<div class="nav-cat">生活指南</div>
<ul>
<li class="active"><a href="#">餐饮旅游</a></li>
<li><a href="#">文化娱乐</a></li>
<li><a href="#">家政服务</a></li>
<li><a href="#">教育培训</a></li>
</ul>
</div>
<!-- 右侧内容 -->
<div class="right-content">
<div class="breadcrumb">
<a href="#">首页</a> > <a href="#">在线调查</a>
</div>
<div class="cat-header"><span>在线调查</span></div>
<div class="survey-area">
<div class="survey-title">对农产品认知情况的调查</div>
<div class="survey-date">发布时间:2020-07-23</div>
<form action="#" method="post">
<!-- Q1 城市 -->
<div class="q-row">
<div class="q-label">Q1:您所在的城市是:</div>
<div class="area-selects">
<select name="province">
<option value="">▼ 省</option>
<option>北京市</option>
<option>上海市</option>
<option>广东省</option>
</select>
<select name="city">
<option value="">▼ 市</option>
</select>
<select name="district">
<option value="">▼ 区/县</option>
</select>
</div>
</div>
<!-- Q2 性别 -->
<div class="q-row">
<div class="q-label">Q2:您的性别:</div>
<div class="options-row">
<label><input type="radio" name="gender" value="male"> 男</label>
<label><input type="radio" name="gender" value="female"> 女</label>
</div>
</div>
<!-- Q3 年龄 -->
<div class="q-row">
<div class="q-label">Q3:您的年龄层次:</div>
<div class="options-row">
<label><input type="radio" name="age" value="1"> 15岁以下</label>
<label><input type="radio" name="age" value="2"> 16岁~35岁</label>
<label><input type="radio" name="age" value="3"> 36岁~60岁</label>
<label><input type="radio" name="age" value="4"> 60岁以上</label>
</div>
</div>
<!-- Q4 学历 -->
<div class="q-row">
<div class="q-label">Q4:您的最高学历:</div>
<div class="options-row">
<label><input type="radio" name="edu" value="1"> 小学及以下</label>
<label><input type="radio" name="edu" value="2"> 初中</label>
<label><input type="radio" name="edu" value="3"> 高中或中专</label>
<label><input type="radio" name="edu" value="4"> 大专或本科</label>
<label><input type="radio" name="edu" value="5"> 研究生以上</label>
</div>
</div>
<!-- Q5 专业 -->
<div class="q-row">
<div class="q-label">Q5:您的所学专业/从事专业领域:</div>
<div class="options-row">
<label><input type="radio" name="major" value="1"> 理工类</label>
<label><input type="radio" name="major" value="2"> 农村类</label>
<label><input type="radio" name="major" value="3"> 人文类</label>
<label><input type="radio" name="major" value="4"> 医学类</label>
<label><input type="radio" name="major" value="5"> 艺术类</label>
<label><input type="radio" name="major" value="6"> 其他</label>
</div>
</div>
<!-- Q6 职业 -->
<div class="q-row">
<div class="q-label">Q6:您目前所从事职业:</div>
<div class="options-row">
<label><input type="radio" name="job" value="1"> 农民</label>
<label><input type="radio" name="job" value="2"> 工人</label>
<label><input type="radio" name="job" value="3"> 学生</label>
<label><input type="radio" name="job" value="4"> 企业职员</label>
<label><input type="radio" name="job" value="5"> 个体经营者</label>
<label><input type="radio" name="job" value="6"> 其他</label>
</div>
</div>
<!-- Q7 关注领域(多选) -->
<div class="q-row">
<div class="q-label">Q7:您经常关注的领域:(可多选)</div>
<div class="options-row">
<label><input type="checkbox" name="interest" value="edu"> 教育</label>
<label><input type="checkbox" name="interest" value="med"> 医疗</label>
<label><input type="checkbox" name="interest" value="agr"> 农业</label>
<label><input type="checkbox" name="interest" value="city"> 城市建设</label>
<label><input type="checkbox" name="interest" value="art"> 人文艺术</label>
<label><input type="checkbox" name="interest" value="other"> 其他</label>
</div>
</div>
<!-- Q8 建议 -->
<div class="q-row">
<div class="q-label">Q8:您对农产品有什么建议(请填述,50字以内)</div>
<textarea class="survey-textarea" name="suggestion" maxlength="50"
placeholder=""></textarea>
</div>
<!-- 提交 -->
<div class="submit-row">
<button type="submit" class="submit-btn">提交</button>
</div>
</form>
</div>
</div>
</div>
<div class="footer-wrap">
<div class="footer-inner">
<p>社区网(www.shequ.cn)*2020 版权所有 All Rights Reserved.</p>
<p>主办单位名称:社区研究会 网站备案号:京ICP备10006066号
营业执照经营许可证编号:京ICP证160666号
京公网安备:11011402010666号</p>
</div>
</div>
</body>
</html>
📖 参见 12.3 制作社区新闻网的列表页(左右两栏布局复用)
这道题要做一个内容丰富的图片新闻聚合页。观察效果图,页面分为几个版块:
完整代码如下(gongyixinwen.html):
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>公益新闻 - 金阳光社区网</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "微软雅黑", sans-serif; font-size: 14px; background: #f0f0f0; color: #333; }
a { text-decoration: none; color: inherit; }
ul, li { list-style: none; }
/* ===== 公用页头样式(与其他页相同) ===== */
.top-bar { width: 100%; height: 8px; background: #d10909; }
.header-top {
width: 1200px; margin: 0 auto;
height: 30px; line-height: 30px;
text-align: right; font-size: 12px; color: #666;
}
.header-top a { margin-left: 10px; color: #666; }
.header-logo {
width: 100%;
background: linear-gradient(135deg, #2a2a2a 0%, #4a4a4a 50%, #2a2a2a 100%);
height: 143px; margin-top: 5px;
}
.header-logo .inner {
width: 1200px; margin: 0 auto;
display: flex; align-items: center;
height: 100%; justify-content: space-between;
}
.logo-title { font-size: 42px; font-weight: bold; color: #fff; letter-spacing: 4px; }
.logo-slogan { font-size: 22px; color: #e0e0e0; letter-spacing: 2px; }
.search-bar {
width: 1200px; margin: 0 auto;
display: flex; justify-content: flex-end;
align-items: center; padding: 8px 0;
}
.search-bar input[type="text"] {
width: 220px; height: 28px;
border: 1px solid #ccc; padding: 0 8px; font-size: 13px; outline: none;
}
.search-bar button {
height: 28px; padding: 0 12px;
background: #555; color: #fff; border: none; cursor: pointer; font-size: 13px;
}
.nav-bar { width: 100%; background: #444; border-top: 2px solid #d10909; }
.nav-bar ul { width: 1200px; margin: 0 auto; display: flex; }
.nav-bar ul li a {
display: block; padding: 0 20px;
height: 42px; line-height: 42px;
color: #fff; font-size: 14px;
}
.nav-bar ul li a:hover,
.nav-bar ul li.active a { background: #d10909; }
/* ===== 主内容包装 ===== */
.content { width: 1200px; margin: 20px auto; }
/* ===== 顶部三栏区域 ===== */
.top-section {
display: flex; gap: 15px; margin-bottom: 20px;
}
/* 版块通用:标题条 */
.block-title {
background: #555; color: #fff;
padding: 8px 12px; font-size: 14px; font-weight: bold;
display: flex; justify-content: space-between; align-items: center;
margin-bottom: 0;
}
.block-title a { color: #ccc; font-size: 12px; font-weight: normal; }
.block-title a:hover { color: #fff; }
/* ===== 爱心点点(左列) ===== */
.aixin-col {
width: 200px; flex-shrink: 0;
background: #fff; border: 1px solid #e0e0e0;
}
.aixin-list { padding: 6px 0; }
.aixin-list li {
display: flex; justify-content: space-between;
align-items: center; padding: 5px 12px;
font-size: 13px; border-bottom: 1px dotted #eee;
color: #555;
}
.aixin-list li:last-child { border-bottom: none; }
.aixin-list .seq { color: #999; width: 20px; }
.aixin-list .pct { color: #d10909; font-weight: bold; flex: 1; text-align: center; }
.aixin-list .date { color: #999; font-size: 12px; }
/* ===== 公益新动(中列) ===== */
.gongy-col {
flex: 1; background: #fff; border: 1px solid #e0e0e0;
}
.news-item {
display: flex; gap: 10px; padding: 10px 12px;
border-bottom: 1px solid #f0f0f0;
}
.news-item:last-child { border-bottom: none; }
.news-img {
width: 80px; height: 58px; flex-shrink: 0;
background: #d0d0d0;
display: flex; align-items: center; justify-content: center;
font-size: 11px; color: #999; overflow: hidden;
}
.news-img img { width: 100%; height: 100%; object-fit: cover; }
.news-text { flex: 1; min-width: 0; }
.news-text .title {
font-size: 13px; color: #333; line-height: 1.5;
margin-bottom: 4px; font-weight: 500;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.news-text .desc { font-size: 12px; color: #888; line-height: 1.6; }
/* ===== 紧急救援(右列) ===== */
.jiuyuan-col {
width: 340px; flex-shrink: 0;
background: #fff; border: 1px solid #e0e0e0;
}
/* ===== 图片新闻版块(下部) ===== */
.pic-section { margin-bottom: 20px; background: #fff; border: 1px solid #e0e0e0; }
.pic-grid {
display: flex; gap: 0; padding: 12px;
}
.pic-item {
flex: 1; text-align: center; padding: 0 6px;
}
.pic-item .img-wrap {
width: 100%; padding-top: 75%; /* 4:3 比例 */
position: relative; background: #c8c8c8;
overflow: hidden;
}
.pic-item .img-wrap img {
position: absolute; top: 0; left: 0;
width: 100%; height: 100%; object-fit: cover;
}
/* 无图时的占位色块 */
.pic-item .img-wrap.ph1 { background: #9aaa9a; }
.pic-item .img-wrap.ph2 { background: #8a9aaa; }
.pic-item .img-wrap.ph3 { background: #aa9a8a; }
.pic-item .img-wrap.ph4 { background: #aaa08a; }
.pic-item .img-label {
font-size: 12px; color: #555;
margin-top: 5px; white-space: nowrap;
overflow: hidden; text-overflow: ellipsis;
}
/* ===== 页脚 ===== */
.footer-wrap { width: 100%; background: #3a3a3a; margin-top: 20px; padding: 30px 0 25px; }
.footer-inner { width: 1200px; margin: 0 auto; text-align: center; color: #ccc; }
.footer-inner p { font-size: 12px; line-height: 26px; }
</style>
</head>
<body>
<div class="top-bar"></div>
<div class="header-top">
<a href="#">登录</a> | <a href="#">注册</a>
</div>
<div class="header-logo">
<div class="inner">
<div class="logo-title">金阳光社区网</div>
<div class="logo-slogan">推进社区发展 服务百姓生活</div>
</div>
</div>
<div class="search-bar">
<input type="text">
<button>站内搜索</button>
</div>
<div class="nav-bar">
<ul>
<li><a href="#">网站首页</a></li>
<li><a href="#">生活指南</a></li>
<li><a href="#">热点关注</a></li>
<li><a href="#">政策解读</a></li>
<li class="active"><a href="#">公益捐赠</a></li>
<li><a href="#">在线调查</a></li>
<li><a href="#">我要留言</a></li>
<li><a href="#">注册加入</a></li>
<li><a href="#">联系我们</a></li>
</ul>
</div>
<div class="content">
<!-- 顶部三栏区域 -->
<div class="top-section">
<!-- 左列:爱心点点 -->
<div class="aixin-col">
<div class="block-title">
爱心点点 <a href="#">更多>></a>
</div>
<ul class="aixin-list">
<li><span class="seq">陈一</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">李二</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">张三</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">周四</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">王五</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">赵六</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">孙七</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">吴八</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">郑九</span><span class="pct">100%</span><span class="date">08-22</span></li>
<li><span class="seq">冯十</span><span class="pct">100%</span><span class="date">08-22</span></li>
</ul>
</div>
<!-- 中列:公益新动 -->
<div class="gongy-col">
<div class="block-title">
公益新动 <a href="#">更多>></a>
</div>
<div class="news-item">
<div class="news-img">图</div>
<div class="news-text">
<div class="title">组织志愿者,帮助孤寡老人开展的志愿活动</div>
<div class="desc">城市的建设是我们共同的事,它们不仅仅是不在意获得的劳务,你手的付出,自绝对比你情情获得更多……</div>
</div>
</div>
<div class="news-item">
<div class="news-img">图</div>
<div class="news-text">
<div class="title">带给孩子们温暖,助力贫困儿童上学梦</div>
<div class="desc">等于我们不该就是这样,给予孩子们温暖,帮助他们实现上学的梦想……</div>
</div>
</div>
<div class="news-item">
<div class="news-img">图</div>
<div class="news-text">
<div class="title">积极参与环保行动,共建绿色美丽家园</div>
<div class="desc">绿色出行,减少污染,是我们每个人的责任……</div>
</div>
</div>
</div>
<!-- 右列:紧急救援 -->
<div class="jiuyuan-col">
<div class="block-title">
紧急救援 <a href="#">更多>></a>
</div>
<div class="news-item">
<div class="news-img">图</div>
<div class="news-text">
<div class="title">洪灾救援行动紧急展开</div>
<div class="desc">握手我们花完到了洪灾,我们花花彻底消除了阻碍,蓝管我们花花很完了这一'以之不不是'的愿望……</div>
</div>
</div>
<div class="news-item">
<div class="news-img">图</div>
<div class="news-text">
<div class="title">地震救灾物资紧急运抵灾区</div>
<div class="desc">第一时间调配救灾物资,确保灾区群众生活物资供应……</div>
</div>
</div>
<div class="news-item">
<div class="news-img">图</div>
<div class="news-text">
<div class="title">消防救援队紧急出动扑灭山火</div>
<div class="desc">消防救援队紧急出动,历经三小时成功扑灭山火……</div>
</div>
</div>
</div>
</div> <!-- /.top-section -->
<!-- 助学圆梦图片版块 -->
<div class="pic-section">
<div class="block-title">
<span>| 助学圆梦</span> <a href="#">更多>></a>
</div>
<div class="pic-grid">
<div class="pic-item">
<div class="img-wrap ph1"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph2"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph3"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph4"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph1"></div>
<div class="img-label">标题</div>
</div>
</div>
</div>
<!-- 紧急救援图片版块 -->
<div class="pic-section">
<div class="block-title">
<span>| 紧急救援</span> <a href="#">更多>></a>
</div>
<div class="pic-grid">
<div class="pic-item">
<div class="img-wrap ph2"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph3"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph4"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph1"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph2"></div>
<div class="img-label">标题</div>
</div>
</div>
</div>
<!-- 公益活动图片版块 -->
<div class="pic-section">
<div class="block-title">
<span>| 公益活动</span> <a href="#">更多>></a>
</div>
<div class="pic-grid">
<div class="pic-item">
<div class="img-wrap ph3"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph4"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph1"></div>
<div class="img-label">标题</div>
</div>
<div class="pic-item">
<div class="img-wrap ph2"></div>
<div class="img-label">标题</div>
</div>
</div>
</div>
</div> <!-- /.content -->
<div class="footer-wrap">
<div class="footer-inner">
<p>社区网(www.shequ.cn)*2020 版权所有 All Rights Reserved.</p>
<p>主办单位名称:社区研究会 网站备案号:京ICP备10006066号
营业执照经营许可证编号:京ICP证160666号
京公网安备:11011402010666号</p>
</div>
</div>
</body>
</html>
📖 参见 12.2–12.4 三个页面的制作(全局样式、布局结构均可复用)