Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:知道自己很棒吗?
1、布局拆分页眉(头部)、主体(内容区)、底部(页脚)
2、头部和尾部用绝对定位,固定
3、主题部分有内容撑开设置overflow属性auto;
4、主题可以分为幻灯片、导航区、商品展示区,基本上都可以通过flex设置自适应布局
5、css重置样式表、布局样式表、头部和尾部以及主题样式
1、代码部分:
1.1、html代码:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>仿京东移动端案例</title>
<link rel="stylesheet" href="static/style/layout.css">
<link rel="stylesheet" href="static/font/iconfont.css">
<link rel="stylesheet" href="static/style/header.css">
<link rel="stylesheet" href="static/style/main.css">
<link rel="stylesheet" href="static/style/footer.css">
</head>
<body>
<header>
<span class="iconfont icon-category"></span>
<div class="search">
<span>JD</span>
<span class="iconfont icon-search"></span>
<input type="search" value="三星硬盘">
</div>
<span><a href="">登陆</a></span>
</header>
<main>
<div>
<div class="banner">
<img src="static/images/banner.jpg" >
</div>
</div>
<div class="slider">
<img src="static/images/bgc%20(2).jpg" alt="">
<img src="static/images/bgc%20(1).jpg" alt="">
<img src="static/images/bgc%20(3).jpg" alt="">
</div>
<nav>
<div><img src="static/images/京东超市.png" alt=""><span>京东超市</span></div>
<div><img src="static/images/数码电器.png" alt=""><span>数码电器</span></div>
<div><img src="static/images/京东服饰.png" alt=""><span>京东服饰</span></div>
<div><img src="static/images/京东生鲜.png" alt=""><span>京东生鲜</span></div>
<div><img src="static/images/京东到家.png" alt=""><span>京东到家</span></div>
<div><img src="static/images/9.9元拼.png" alt=""><span>9.9元拼</span></div>
<div><img src="static/images/领卷.png" alt=""><span>领卷</span></div>
<!-- <div><img src="static/images/借钱.png" alt=""><span>借钱</span></div> -->
<div><img src="static/images/PLUS会员.png" alt=""/><span>PLUS会员</span></div>
<div><img src="static/images/充值缴费.png" alt=""><span>充值缴费</span></div>
<div><img src="static/images/领金贴.png" alt=""><span>领金贴</span></div>
</nav>
<div class="ms">
<div>
<img src="static/images/products%20(3).jpg" alt="">
<span>满499减150</span>
<span>双旦礼遇季</span>
</div>
<div>
<img src="static/images/products%20(4).jpg" alt="">
<span>满499减150</span>
<span>双旦礼遇季</span>
</div>
<div>
<img src="static/images/products%20(3).jpg" alt="">
<span>满499减150</span>
<span>双旦礼遇季</span>
</div>
<div>
<img src="static/images/products%20(4).jpg" alt="">
<span>满499减150</span>
<span>双旦礼遇季</span>
</div>
</div>
<div class="shop">
<img src="static/images/guess-like.png" alt="">
<div class="shop-detail">
<div>
<img src="static/images/products%20(2).jpg" alt="">
<p>商品介绍商品介绍商品介绍商品介绍商品介绍商</p>
<div><span>¥89</span> <span>看相似</span></div>
</div>
<div>
<img src="static/images/products%20(2).jpg" alt="">
<p>商品介绍商品介绍商品介绍商品介绍商品介绍</p>
<div><span>¥89</span> <span>看相似</span></div>
</div>
<div>
<img src="static/images/products%20(2).jpg" alt="">
<p>商品介绍商品介绍商品介绍商品介绍商品介绍商品</p>
<div><span>¥89</span> <span>看相似</span></div>
</div>
<div>
<img src="static/images/products%20(2).jpg" alt="">
<p>商品介绍商品介绍商品介绍商品介绍商品介绍商品</p>
<div><span>¥89</span> <span>看相似</span></div>
</div>
<div>
<img src="static/images/products%20(2).jpg" alt="">
<p>商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍</p>
<div><span>¥89</span> <span>看相似</span></div>
</div>
<div>
<img src="static/images/products%20(2).jpg" alt="">
<p>商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商</p>
<div><span>¥89</span> <span>看相似</span></div>
</div>
</div>
</div>
</main>
<footer>
<a href=""><img src="static/images/icon%20(4).png" alt=""></a>
<a href=""><img src="static/images/icon%20(1).png" alt=""></a>
<a href=""><img src="static/images/icon%20(3).png" alt=""></a>
<a href=""><img src="static/images/icon%20(5).png" alt=""></a>
<a href=""><img src="static/images/icon%20(2).png" alt=""></a>
</footer>
</body>
</html>
1.2、css样式:
/*重置样式*/
*{
padding: 0;
margin: 0;
box-sizing: border-box;
border: none;
}
ul{
list-style: none;
}
a{
text-decoration: none;
}
html{
font-size: 10px;
}
body{
background-color: #f6f6f6;
}
/* 布局 */
@import url("resetCSS.css");
header{
height:5rem ;
background-color: #c72518;
color:#FFFFFF;
position: fixed;
top:0;
left: 0;
right:0;
}
footer{
height:5rem ;
background-color: #fff;
position: fixed;
bottom:0;
left: 0;
right:0;
}
main{
position: fixed;
top:5rem;
left:0;
right:0;
bottom: 5rem;
overflow: auto;
}
/* 头部样式 */
@import url("resetCSS.css");
header{
display: flex;
justify-content: space-between;
/* font-size: 1.6rem; */
align-items: center;
/* padding:0 0.8rem ; */
}
header > .search{
background-color: #fff;
height: 2.9rem;
border-radius: 2rem;
flex:8;
padding: 0 1.2rem;
}
header > span {
width: 5.5rem;
font-size: 1.4rem;
text-align: center;
flex: 1.3;
}
header > span.iconfont.icon-category{
font-size: 3rem;
flex: 1;
}
header > span > a{
color:white;
text-align: center;
}
header > .search{
display: flex;
align-items: center;
justify-content: space-around;
}
header > .search > span:first-child {
color:red;
font-size: 2rem;
font-weight: bold;
margin-right: 0.8rem;
}
header > .search > .iconfont.icon-search{
font-size: 2.2rem;
color:lightgrey;
border-left: 1px solid #D3D3D3;
padding: 0 .4rem;
}
header > .search > input{
border: none;
outline: none;
height: 2.9rem;
font-size: 1.6rem;
flex: 3;
color:#CCCCCC;
}
/* main主体样式 */
@import url("resetCSS.css");
main{
display: flex;
flex-flow: column nowrap;
}
main > div {
height: 20rem;
}
main> div >.banner{
background-color: #c72518;
height: 10rem;
text-align: center;
border: none;
border-bottom-right-radius:4rem;
border-bottom-left-radius: 4rem;
}
main> div >.banner> img{
height: 16rem;
width: 90vw;
border-radius: 1rem;
}
main > .slider{
margin-top: 5rem ;
width: 100vw;
display: flex;
justify-content: center;
}
main > .slider >img{
width: 33.333%;
}
main > nav {
width: 100vw;
display: flex;
flex-flow:row wrap;
justify-content: space-evenly;
}
main > nav > div {
width: 20vw;
display: flex;
flex-flow: column nowrap;
align-items: center;
column-rule: #999;
}
main > nav > div >img {
width: 16vw;
}
main > .ms {
margin-top: 1rem;
display: flex;
width: 100vw;
justify-content: space-evenly;
}
main > .ms > div {
display: flex;
flex-flow: column nowrap;
width: 22vw;
height: 12rem;
align-items: center;
justify-content: space-around;
color: white;
font-size: 1em;
background-color: #e6272f;
border-radius: 1rem;
}
main > .ms >div > img{
background-color: #fff;
border-radius: 1rem;
width: 18vw;
}
main > .ms >div > span:first-of-type{
background-color: #69a69f;
border-radius: 1rem;
width: 18vw;
font-size: 0.4em;
height: 2rem;
text-align: center;
line-height: 2rem;
position: relative;
top:-2rem;
}
main > .ms > div > span:last-of-type{
font-size: 1.4rem;
margin-top:-2.4rem;
}
main > .shop {
display: flex;
flex-flow:column nowrap;
align-items: center;
}
main > .shop > img {
width: 90vw;
margin-top:1rem;
}
main > .shop >.shop-detail {
display: flex;
flex-flow: row wrap;
/* width: 100vw; */
justify-content: space-evenly;
}
main > .shop >.shop-detail > div{
display: flex;
flex-flow: column nowrap;
width: 46vw;
margin-top: 1rem;
}
main >.shop > .shop-detail > div > img {
/* background-color: red; */
border-radius: 1rem;
}
main >.shop > .shop-detail > div > div{
display: flex;
justify-content: space-between;
}
main >.shop > .shop-detail > div > div >span:first-child{
color:red;
}
main >.shop > .shop-detail > div > div >span:last-child{
background-color: #969896;
border-radius: 0.8rem;
width: 4rem;
text-align: center;
}
/* 底部样式 */
@import url("resetCSS.css");
footer{
display: flex;
justify-content: space-evenly;
align-items: center;
}
footer>a>img{
width: 7rem;
}
1.3、运行结果