项目案例
目标:实现有路网首页布局
样式重置
一些元素带有默认样式,在制作页面时往往需要计算,为了方便,可以清空重置元素的默认样式,reset.css
css
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
font-family:"Microsoft YaHei", "宋体" ;
font-size: 12px;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
.clear{
clear: both;
}
整体体框架
实现代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="../style/reset.css" rel="stylesheet" />
<style>
.header{
height: 29px;
background-color: #F4F4F4;
}
.search{
height: 64px;
width: 1200px;
background-color: #0000FF;
margin: 0 auto;
margin-top:40px ;
}
.nav{
height: 39px;
margin-top: 28px;
background-color: #D80000;
}
.wrapSlide{
width: 1200px;
background-color: #98FB98;
margin: 0 auto;
border: solid 1px black;
}
.wrapSlide .left,.wrapSlide .right{
float: left;
}
.wrapSlide .left{
width: 210px;
height: 968px;
background-color: #6495ED;
}
.wrapSlide .right{
width: 990px;
height: 968px;
background-color: #55ffff;
}
.clear{
clear: both;
}
.helpBar{
border: dashed 1px #CD853F;
height: 30px;
}
.wrapContent .wrapContentL, .wrapContent .wrapContentR{
float: left;
}
.wrapContent .wrapContentL{
width: 750px;
height: 940px;
border: solid 2px #D80000;
}
.wrapContent .wrapContentR{
width: 200px;
height: 940px;
border: solid 2px #ffff00;
}
</style>
</head>
<body>
<div class="header"> </div>
<div class="search"> </div>
<div class="nav"> </div>
<div class="wrapSlide">
<div class="left">
</div>
<div class="right">
<div class="helpBar"></div>
<div class="wrapContent">
<div class="wrapContentL">left</div>
<div class="wrapContentR">right</div>
<div class="clear"></div>
</div>
</div>
<div class="clear"></div>
</div>
</body>
</html>
头部导航
代码实现
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="../style/reset.css" rel="stylesheet" />
<style>
.header{
background-color: #F4F4F4;
height: 30px;
}
.header .left ,.header .right{
display: inline-block;
line-height:30px ;
}
.header .left{
margin-left:110px ;
}
.header .right{
margin-left: 500px;
}
</style>
</head>
<body>
<div class="header">
<div class="left"> 您好,欢迎光临有路网!</div>
<div class="right"> <span style="color: red;">请登陆</span> <span class="borderright" >免费注册</span>
<span class="borderright" >我的有路 </span>
<span class="borderright" >我要开店 </span>
<span class="borderright" >有路公众号 </span>
<span class="borderright" >团购批发 </span>
<span>客服服务</span>
</div>
</div>
</body>
</html>
搜索框
代码实现
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="../style/reset.css" rel="stylesheet" />
<style>
.search {
/* width: 496px; */
height: 40px;
}
.search .logo , .search .searchform ,.search .cart{
float: left;
/* display: inline-block; */
}
.search .logo{
width: 355px;
/* border: solid 1px black; */
}
.search .searchform{
width: 500px;
margin-left: 120px;
}
.search .cart{
width: 129px;
height: 40px ;
border: solid 1px black;
background-image: url(../img/cart.jpg);
background-repeat:no-repeat;
padding-left: 45px;
margin-left: 60px;
}
.search .inp{
border: solid 3px red;
height:34px ;
width: 400px;
padding: 5px;
}
.search .btn{
background-color: red;
width: 73px;
height:50px ;
margin-left: -6px;
display: inline-block;
border: 0px;
letter-spacing:5px;
font-size: 18px;
font-weight: 700;
color: white;
vertical-align: top;
}
</style>
</head>
<body>
<div class="search">
<div class="logo">
<img src="../img/logo.jpg" />
</div>
<div class="searchform">
<form>
<input type="text" class="inp" placeholder="书名">
<input type="button" value="搜索" class="btn">
</form>
</div>
<div class="cart"> 购物车</div>
<div class="clear"></div>
</div>
</body>
</html>
导航栏
代码实现
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="../style/reset.css" rel="stylesheet" />
<style>
.nav{
height: 39px;
margin-top: 28px;
background-color: #D80000;
}
.nav .content{
width: 1200px;
height: 100%;
margin: 0 auto;
border: solid 1px orange;
}
.nav .content span{
display: inline-block;
height: 39px;
line-height:39px ;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
.nav .content .nav_c_l ul{
width: 530px;
line-height: 39px;
}
.nav .content .nav_c_l li{
display: inline-block;
line-height: 39px;
height: 39px;
padding-left: 20px;
padding-right: 20px;
padding-top: 0px;
}
.nav .content .nav_c_l li:hover{
background-color: #7a0000;
}
.nav .content .nav_c_l li a{
text-decoration: none;
}
.nav .content .nav_c_l li a:link{
color:#C8C8C8;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
.nav .content .nav_c_l li a:visited{
color:#C8C8C8;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
.nav .content .nav_c_l li a:hover{
color:#ec7814;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
.nav .content .nav_c_l li a:active{
color:#aaff00;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
</style>
</head>
<body>
<div class="nav">
<div class="content">
<span>全部图书分类</span>
<ul class="nav_c_l" style="display: inline-block;">
<li ><a href="/">首页</a></li>
<li><a href="/usedBookRecycling/">旧书回收</a></li>
<li><a href="/classify/">分类</a></li>
<li><a href="/newShopList2/">入驻书店</a></li>
<li><a href="/newGoods/">文具</a></li>
<li><a href="http://ebook.youlu.net/" target="_blank">电子书</a></li>
</ul>
</div>
</div>
</body>
</html>
左侧图书索引菜单
代码实现
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="../style/reset.css" rel="stylesheet" />
<style>
.left{
width: 210px;
height: 968px;
background-color: #6495ED;
border-left: solid 1px lightgrey;
border-right: solid 1px lightgrey;
}
.left ul{
width: 100%;
}
.left ul li{
width: 100%;
list-style: none;
/* margin-left: -40px; */
padding-top: 5px;
padding-left: 10px;
border-bottom: dashed 1px lightgrey;
}
.left ul li:hover{
background-color: red;
}
.left ul li h3{
font-size: 20px;
font-weight: 700;
}
.left ul li a{
margin: 5px;
display: inline-block;
}
.left ul li a:link{
color:#696969;;
}
.left ul li a:visited{
color:#C8C8C8;
}
.left ul li a:hover{
color:#ffffff;;
}
.left ul li a:active{
color:#C8C8C8;
}
</style>
</head>
<body>
<div class="left">
<ul>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
<a href="#">市场营销</a>
</li>
</ul>
</div>
</body>
</html>
帮助条
图片轮播图
书籍轮播图
黑板报
代码实现
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="../style/reset.css" rel="stylesheet" />
<style>
.balckcast a:link{
color:#696969;;
}
.balckcast a:visited{
color:#C8C8C8;
}
.balckcast a:hover{
color:#ec7814;;
}
.balckcast a:active{
color:#C8C8C8;
}
.balckcast li{
padding-left: 15px;
}
</style>
</head>
<body>
<div class="balckcast">
<h2>黑板报</h2>
<ul>
<li><a href="#">中秋国庆双节放假通知</a></li>
<li><a href="#">2020年团购全国包邮</a></li>
<li><a href="#">2020秋季延迟发货开启</a></li>
<li><a href="#">分享领佣金</a></li>
</ul>
<hr/>
<h2>购物指南</h2>
<ul>
<li><a href="#">支付宝担保交易,安全快捷</a></li>
<li><a href="#">保证24小时之内发货</a></li>
<li><a href="#">赠送积分,积分可用于支付</a></li>
<li><a href="#">收货后7天内可以无理由退货</a></li>
<li><a href="#">提供电子商务小包、EMS、快递</a></li>
<li><a href="#">配送造成的所有损失由我们承担</a></li>
<li><a href="#">提供免费短信提醒服务</a></li>
</ul>
</div>
</body>
</html>
目前的整合效果
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link href="../style/reset.css" rel="stylesheet" />
<style>
/* 1 头部 */
.header{
background-color: #F4F4F4;
height: 30px;
}
.header .left ,.header .right{
display: inline-block;
line-height:30px ;
}
.header .left{
margin-left:110px ;
}
.header .right{
margin-left: 500px;
}
/* 2 搜索框 */
.search{
height: 64px;
width: 1200px;
/* background-color: #0000FF; */
margin: 0 auto;
margin-top:40px ;
}
.search .logo , .search .searchform ,.search .cart{
float: left;
/* display: inline-block; */
}
.search .logo{
width: 355px;
/* border: solid 1px black; */
}
.search .searchform{
width: 500px;
margin-left: 110px;
}
.search .cart{
width: 129px;
height: 40px ;
border: solid 1px black;
background-image: url(../img/cart.jpg);
background-repeat:no-repeat;
padding-left: 45px;
margin-left: 59px;
}
.search .inp{
border: solid 3px red;
height:34px ;
width: 400px;
padding: 5px;
}
.search .btn{
background-color: red;
width: 73px;
height:50px ;
margin-left: -6px;
display: inline-block;
border: 0px;
letter-spacing:5px;
font-size: 18px;
font-weight: 700;
color: white;
vertical-align: top;
}
/* 3 导航条 */
.nav{
height: 39px;
margin-top: 28px;
background-color: #D80000;
}
.nav .content{
width: 1200px;
height: 100%;
margin: 0 auto;
/* border: solid 1px orange; */
}
.nav .content span{
display: inline-block;
height: 39px;
line-height:39px ;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
width: 210px;
}
.nav .content .nav_c_l ul{
width: 530px;
line-height: 39px;
}
.nav .content .nav_c_l li{
display: inline-block;
line-height: 39px;
height: 39px;
padding-left: 20px;
padding-right: 20px;
padding-top: 0px;
}
.nav .content .nav_c_l li:hover{
background-color: #7a0000;
}
.nav .content .nav_c_l li a{
text-decoration: none;
}
.nav .content .nav_c_l li a:link{
color:#C8C8C8;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
.nav .content .nav_c_l li a:visited{
color:#C8C8C8;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
.nav .content .nav_c_l li a:hover{
color:#ec7814;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
.nav .content .nav_c_l li a:active{
color:#aaff00;
font-family: "Microsoft YaHei", "宋体";
font-size: 15px;
font-weight: 700;
color: white;
}
/* 正文 */
.wrapSlide{
width: 1200px;
background-color: #98FB98;
margin: 0 auto;
border: solid 1px black;
}
.wrapSlide .left,.wrapSlide .right{
float: left;
}
/* 图书索引菜单 */
.wrapSlide .left{
width: 210px;
height: 968px;
background-color: #6495ED;
}
.wrapSlide .left{
width: 210px;
height: 968px;
background-color: #6495ED;
/* border-left: solid 1px lightgrey;
border-right: solid 1px lightgrey; */
}
.wrapSlide .left ul{
width: 200px;
}
.wrapSlide .left ul li{
width: 210px;
list-style: none;
/* margin-left: -40px; */
padding-top: 10px;
padding-left: 10px;
padding-bottom: 10px;
border-bottom: dashed 1px lightgrey;
}
.wrapSlide .left ul li:hover{
background-color: red;
}
.wrapSlide .left ul li h3{
font-size: 20px;
font-weight: 700;
margin-bottom: 20px;
}
.wrapSlide .left ul li a{
margin: 5px 10px;
display: inline-block;
}
.wrapSlide .left ul li a:link{
color:#696969;;
}
.wrapSlide .left ul li a:visited{
color:#C8C8C8;
}
.wrapSlide .left ul li a:hover{
color:#ffffff;;
}
.wrapSlide .left ul li a:active{
color:#C8C8C8;
}
.wrapSlide .right{
width: 990px;
height: 968px;
background-color: #55ffff;
}
/* 帮助条 */
.helpBar{
border: dashed 1px #CD853F;
height: 30px;
}
.wrapContent .wrapContentL, .wrapContent .wrapContentR{
float: left;
}
.wrapContent .wrapContentL{
width: 750px;
height: 940px;
border: solid 2px #D80000;
margin-left: 10px;
margin-right: 20px;
}
.wrapContent .wrapContentR{
width: 200px;
height: 940px;
border: solid 2px #ffff00;
}
.wrapContent .wrapContentR a:link{
color:#696969;;
}
.wrapContent .wrapContentR a:visited{
color:#C8C8C8;
}
.wrapContent .wrapContentR a:hover{
color:#ec7814;;
}
.wrapContent .wrapContentR a:active{
color:#C8C8C8;
}
.wrapContent .wrapContentR li{
padding-left: 15px;
}
</style>
</head>
<body>
<!-- <div class="header"> </div> -->
<div class="header">
<div class="left"> 您好,欢迎光临有路网!</div>
<div class="right"> <span style="color: red;">请登陆</span> <span class="borderright" >免费注册</span>
<span class="borderright" >我的有路 </span>
<span class="borderright" >我要开店 </span>
<span class="borderright" >有路公众号 </span>
<span class="borderright" >团购批发 </span>
<span>客服服务</span>
</div>
</div>
<div class="search">
<div class="logo">
<img src="../img/logo.jpg" />
</div>
<div class="searchform">
<form>
<input type="text" class="inp" placeholder="书名">
<input type="button" value="搜索" class="btn">
</form>
</div>
<div class="cart"> 购物车</div>
<div class="clear"></div>
</div>
<!-- 导航-->
<div class="nav">
<div class="content">
<span>全部图书分类</span>
<ul class="nav_c_l" style="display: inline-block;">
<li ><a href="/">首页</a></li>
<li><a href="/usedBookRecycling/">旧书回收</a></li>
<li><a href="/classify/">分类</a></li>
<li><a href="/newShopList2/">入驻书店</a></li>
<li><a href="/newGoods/">文具</a></li>
<li><a href="http://ebook.youlu.net/" target="_blank">电子书</a></li>
</ul>
</div>
</div>
<div class="wrapSlide">
<div class="left">
<ul>
<li>
<h3>经济管理</h3>
<a href="#">市场</a>
<a href="#">经济学动力</a>
<a href="#">国际贸易</a>
<a href="#">物流管理</a>
<a href="#">管理学原理</a>
<a href="#">财务管理</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">经济学动力</a>
<a href="#">国际贸易</a>
<a href="#">物流管理</a>
<a href="#">管理学原理</a>
<a href="#">财务管理</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">经济学动力</a>
<a href="#">国际贸易</a>
<a href="#">物流管理</a>
<a href="#">管理学原理</a>
<a href="#">财务管理</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">经济学动力</a>
<a href="#">国际贸易</a>
<a href="#">物流管理</a>
<a href="#">管理学原理</a>
<a href="#">财务管理</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">经济学动力</a>
<a href="#">国际贸易</a>
<a href="#">物流管理</a>
<a href="#">管理学原理</a>
<a href="#">财务管理</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">经济学动力</a>
<a href="#">国际贸易</a>
<a href="#">物流管理</a>
<a href="#">管理学原理</a>
<a href="#">财务管理</a>
</li>
<li>
<h3>经济管理</h3>
<a href="#">市场营销</a>
<a href="#">经济学动力</a>
<a href="#">国际贸易</a>
<a href="#">物流管理</a>
<a href="#">管理学原理</a>
<a href="#">财务管理</a>
</li>
</ul>
</div>
<div class="right">
<div class="helpBar"></div>
<div class="wrapContent">
<div class="wrapContentL">
<img src="../img/lunbo1.jpg" width="750" height="340"/>
</div>
<div class="wrapContentR">
<h2>黑板报</h2>
<ul>
<li><a href="#">中秋国庆双节放假通知</a></li>
<li><a href="#">2020年团购全国包邮</a></li>
<li><a href="#">2020秋季延迟发货开启</a></li>
<li><a href="#">分享领佣金</a></li>
</ul>
<hr/>
<h2>购物指南</h2>
<ul>
<li><a href="#">支付宝担保交易,安全快捷</a></li>
<li><a href="#">保证24小时之内发货</a></li>
<li><a href="#">赠送积分,积分可用于支付</a></li>
<li><a href="#">收货后7天内可以无理由退货</a></li>
<li><a href="#">提供电子商务小包、EMS、快递</a></li>
<li><a href="#">配送造成的所有损失由我们承担</a></li>
<li><a href="#">提供免费短信提醒服务</a></li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
<div class="clear"></div>
</div>
</body>
</html>
