第七天笔记
综合页面设计
项目目录
网站根目录是指存放网站的第一层文件夹,内部包含当前网站的所有素材,包含HTML、cSS、图片、JavaScript等等。
- study
- images 文件夹:存放固定使用的图片素材,例如:logo、样式修饰图等等
- uploads 文件夹:存放非固定使用的图片素材,例如:商品图、宣传图需要上传的图片
- css 文件夹:存放 CSS 文件( link 标签引入)
- base.css:基础公共样式,例如:清除默认样式、设置网页基本样式
- index.css:首页 CSS 样式
- index.html:首页 HTML 文件
网页制作思路
- 布局思路:先整体再局部,从外到内,从上到下,从左到右
- css 实现思路
- 画盒子,调整盒子范围 → 宽高背景色
- 调整盒子位置 → flex 布局、内外边距
- 控制图片、文字内容样式
网页预览

布局设计
- 通栏:宽度与浏览器窗口相同的盒子
- 标签结构:通栏 > 版心 > logo + 导航 + 搜索 + 用户
logo 区域 - 布局与功能
- logo功能
- 单击跳转到首页
- 搜索引擎优化:提升网站百度搜索排名
- 实现方法
- 标签结构:h1 > a > 网站名称(搜索关键字)
- css 样式
导航(nav)区域 - 布局与功能
- 导航功能
- 实现方法
- 标签结构:ul > li * 3 > a
- 优势:避免堆砌 a 标签,网站搜索排名降级
- 布局思路
- li 设置 右侧 margin
- a 设置 左右 padding
搜索(search)区域 - 布局与功能
- 实现方法
- 标签结构:.search > input + a / button
用户(user)区域 - 布局与功能
- 实现方法
- 标签结构:.user > a > img + span
banner 区域 - 布局与功能
- 实现方法
- 标签结构:通栏 banner > 版心 > .left + .right
左侧导航栏(left)
- 实现方法
- 标签结构:.left > ul > li * 9 > a
- 布局思路:a 默认状态:背景图为白色右箭头
右侧课程表(right)
- 实现方法
- 标签结构:.right > h3 + .content
精品推荐(recommend)区域 - 布局和功能
- 实现方法
- 标签结构:.recommend > h3 + ul + a.modify
- 布局思路:flex 布局
精品课程(course)区域 - 布局和功能
- 实现方法
base.css
* { margin: 0; padding: 0; box-sizing: border-box; }
li { list-style: none; }
body { font: 14px/1.5 "Microsoft Yahei", "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif; color: #333; }
a { color: #333; text-decoration: none; }
|
index.css
.wrapper { margin: 0 auto; width: 1200px; }
body { background-color: #f3f5f7; }
.header { height: 100px; background-color: #fff; }
.header .wrapper { padding-top: 29px; display: flex; }
.logo a { display: block;
width: 195px; height: 41px; background-image: url(../images/logo.png);
font-size: 0; }
.nav { margin-left: 102px; }
.nav ul { display: flex; }
.nav ul li { margin-right: 24px; }
.nav ul a { display: block; padding: 6px 8px;
line-height: 27px; font-size: 19px; }
.nav li .active, .nav li a:hover { border-bottom: 2px solid #00a4ff; }
.search { display: flex; margin-left: 64px; padding-left: 19px; padding-right: 12px; width: 412px; height: 40px; background-color: #f3f5f7; border-radius: 20px; }
.search input { flex: 1; border: 0; background-color: transparent; outline: none; }
.search::placeholder { font-size: 14px; color: #999; }
.search a { align-self: center;
width: 16px; height: 16px; background-image: url(../images/search.png); }
.user { margin-left: 32px; margin-top: 4px; }
.user img { margin-right: 7px; vertical-align: middle; }
.user span { font-size: 16px; color: #666 }
.banner { height: 420px; background-color: #0092cd; }
.banner .wrapper { display: flex; justify-content: space-between; height: 420px; background-image: url(../uploads/banner.png); }
.banner .left { padding: 3px 20px;
width: 191px; height: 420px; background-color: rgba(0, 0, 0, 0.42); }
.banner .left a { display: block;
height: 46px; background: url(../images/right.png) no-repeat right center;
line-height: 46px;
font-size: 16px; color: #fff; }
.banner .left a:hover { background-image: url(../images/right-hover.png); color: #00a4ff; }
.banner .right { margin-top: 60px; width: 218px; height: 305px; background-color: #209dd5; border-radius: 10px; }
.banner .right h3 { margin-left: 14px; height: 48px; line-height: 48px; font-size: 15px; color: #fff; font-weight: 400; }
.right .content { padding: 14px; height: 257px; background-color: #fff; border-radius: 10px; }
.banner .right dl { margin-bottom: 12px; border-bottom: 1px solid #e0e0e0; }
.banner .right dt { margin-bottom: 8px; font-size: 14px; line-height: 20px; font-weight: 700; }
.banner .right dd { margin-bottom: 8px; font-size: 12px; line-height: 16px; }
.banner .right dd span { color: #00a4ff; }
.banner .right dd strong { color: #7d7d7d; font-weight: 400; }
.banner .right a { display: block; height: 32px; background-color: #00a4ff; text-align: center; line-height: 32px; font-size: 14px; color: #fff; border-radius: 15px; }
.recommend { display: flex; margin-top: 11px; padding: 0 20px; height: 60px; background-color: #fff; box-shadow: 0px 1px 2px 0px rgba(211, 211, 211, 0.5); line-height: 60px; }
.recommend h3 { font-size: 18px; color: #00a4ff; font-weight: 400; }
.recommend ul { display: flex; flex: 1; }
.recommend ul li a { padding: 0 24px; border-right: 1px solid #e0e0e0;; font-size: 18px; }
.recommend ul li:last-child a { border-right: none; }
.recommend .modify { font-size: 16px; color: #00a4ff; }
.course { margin-top: 15px; }
.hd { display: flex; justify-content: space-between; height: 60px; line-height: 60px; }
.hd h3 { font-size: 21px; font-weight: 400; }
.hd .more { padding-right: 20px; background: url(../images/more.png) no-repeat right center; font-size: 14px; color: #999; }
.bd ul { display: flex; flex-wrap: wrap; justify-content: space-between; }
.bd li { margin-bottom: 14px; width: 228px; height: 271px; background-color: pink; }
.bd li .pic { height: 156px; }
.bd li .text { padding: 20px; height: 115px; background-color: #fff; }
.bd li .text h4 { margin-bottom: 13px; height: 40px; font-size: 14px; line-height: 20px; font-weight: 400; }
.bd li .text p { font-size: 14px; line-height: 20px; color: #999; }
.bd li .text p span { color: #fa6400; }
.bd li .text p i { font-style: normal; }
.hd ul { display: flex; }
.hd li { margin-right: 60px; font-size: 16px; }
.hd li .active { color: #00a4ff; }
.hd li a:hover { color: #00a4ff; }
.bd { display: flex; justify-content: space-between; }
.bd .left { width: 228px; }
.bd .right { width: 957px; }
.bd .right .top { margin-bottom: 15px; height: 100px; }
.footer { margin-top: 60px; padding-top: 60px; height: 273px; background-color: #fff; }
.footer .wrapper { display: flex; justify-content: space-between; }
.footer .left { width: 440px; }
.footer .left p { margin-top: 24px; margin-bottom: 14px; font-size: 12px; line-height: 17px; color: #666; }
.footer .left .download { display: block; width: 120px; height: 36px; border: 1px solid #00a4ff; text-align: center; line-height: 34px; font-size: 16px; color: #00a4ff; }
.footer .right { display: flex; }
.footer .right dl { margin-left: 130px; }
.footer .right dt { margin-bottom: 12px; font-size: 16px; line-height: 23px; }
.footer .right a { font-size: 14px; color: #666; line-height: 24px; }
.footer .right a:hover { color: #00a4ff; }
|
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>学成在线</title> <link rel="stylesheet" href="./css/base.css"> <link rel="stylesheet" href="./css/index.css"> </head> <body> <div class="header"> <div class="wrapper"> <div class="logo"> <h1><a href="#">学成在线</a></h1> </div> <div class="nav"> <ul> <li><a href="#" class="active">首页</a></li> <li><a href="#">课程</a></li> <li><a href="#">职业规划</a></li> </ul> </div> <div class="search"> <input type="text" placeholder="请输入关键字词"> <a href="#"></a> </div> <div class="user"> <a href="#"> <img src="./uploads/user.png" alt=""> <span>前端用户</span> </a> </div> </div> </div>
<div class="banner"> <div class="wrapper"> <div class="left"> <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><a href="#">UI设计</a></li> <li><a href="#">产品</a></li> </ul> </div> <div class="right"> <h3>我的课程表</h3> <div class="content"> <dl> <dt>数据可视化课程</dt> <dd><span>正在学习</span>-<strong>echarts使用步骤</strong></dd> </dl> <dl> <dt>Vue3医疗项目课程</dt> <dd><span>正在学习</span>-<strong>认识组合式API</strong></dd> </dl> <dl> <dt>React核心技术课程</dt> <dd><span>正在学习</span>-<strong>rudex配合TS使用</strong></dd> </dl> <a href="#">全部课程</a> </div> </div> </div> </div>
<div class="recommend wrapper"> <h3>精品推荐</h3> <ul> <li><a href="#">HTML</a></li> <li><a href="#">CSS</a></li> <li><a href="#">JavaScript</a></li> <li><a href="#">Node.js</a></li> <li><a href="#">Ajax</a></li> <li><a href="#">Vue2.0</a></li> <li><a href="#">Vue3.0</a></li> <li><a href="#">TypeScript</a></li> <li><a href="#">React</a></li> </ul> <a href="#" class="modify">修改兴趣</a> </div>
<div class="course wrapper"> <div class="hd"> <h3>精品推荐</h3> <a href="#" class="more">查看全部</a> </div> <div class="bd"> <ul> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> </ul> </div> </div>
<div class="wrapper"> <div class="hd"> <h3>前端开发工程师</h3> <ul> <li><a href="#" class="active">热门</a></li> <li><a href="#">初级课程</a></li> <li><a href="#">中级课程</a></li> <li><a href="#">高级课程</a></li> </ul> <a href="#" class="more">查看全部</a> </div> <div class="bd"> <div class="left"> <img src="./uploads/web_left.png" alt=""> </div> <div class="right"> <div class="top"><img src="./uploads/web_top.png" alt=""></div> <div class="bottom"> <ul> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> <li> <a href="#"> <div class="pic"><img src="./uploads/course01.png" alt=""></div> <div class="text"> <h4>JavaScript数据看板项目实战</h4> <p><span>高级</span> - <i>1126</i>人在学习</p> </div> </a> </li> </ul> </div> </div> </div> </div>
<div class="footer"> <div class="wrapper"> <div class="left"> <a href="#"><img src="./images/logo.png" alt=""></a> <p>学成在线致力于普及中国最好的教育它与中国一流大学和机构合作提供在线课程。 © 2017年XTCG Inc.保留所有权利。-沪ICP备15025210号</p> <a href="#" class="download">下载APP</a> </div> <div class="right"> <dl> <dt>合作伙伴</dt> <dd><a href="#">合作机构</a></dd> <dd><a href="#">合作导师</a></dd> </dl> <dl> <dt>合作伙伴</dt> <dd><a href="#">合作机构</a></dd> <dd><a href="#">合作导师</a></dd> </dl> <dl> <dt>合作伙伴</dt> <dd><a href="#">合作机构</a></dd> <dd><a href="#">合作导师</a></dd> </dl> </div> </div> </div> </body> </html>
|
总结
如代码中注释