效果图:
1. 准备工作
方案: 单独制作移动页面方案
2. 搭建相关文件夹结构
3 .设置视口标签以及引入初始化样式
4.html代码如下:
<body><!-- 主心 --><div class="xin"><!-- 导航部分 --><div class="nav"><a href="" class="nav2"></a><input type="text" placeholder="请输入内容"><a href="" class="nav1">登陆</a><span class="nav3"></span></div><!-- 图片 --><img src="uploads/slide_1.jpg" alt="" width="100%"><!-- 图片 --><div class="tu"><ul><li><img src="img/nav_1.png" alt=""><div>京东商品</div></li><li><img src="img/nav_2.png" alt=""><div>全球购</div></li><li><img src="img/nav_3.png" alt=""><div>充值中心</div></li><li><img src="img/nav_4.png" alt=""><div>服装城</div></li><li><img src="img/nav_5.png" alt=""><div>理财</div></li><li><img src="img/nav_6.png" alt=""><div>领券</div></li><li><img src="img/nav_7.png" alt=""><div>查看物流</div></li><li><img src="img/nav_8.png" alt=""><div>我的关注</div></li> </ul></div><!-- 过度 --><div class="guodu"></div><!-- 秒杀 --><div class="ms"><div class="ms1"><ul><li><div class="ms2"></div></li><li class="ms3"><a href="">掌上秒杀</a></li><li class="ms4"><span class="ms5">02</span></li><li class="ms4">:</li><li class="ms4"><span class="ms5">56</span></li><li class="ms4">:</li><li class="ms4"><span class="ms5">24</span></li></ul><ul class="right"><li class="left ms6">更多秒杀 </li><li class="left ms6">></li></ul></div><!-- 假奶粉 --><div class="hz left"><ul><li class="rm1"><img src="uploads/seckill_1.jpg" alt=""><b>热卖</b><div><strong>¥79</strong><br><del>¥118</del></div></li><li><img src="uploads/seckill_2.jpg" alt=""><b>热卖</b><div><strong>¥79</strong><br><del>¥118</del></div></li><li><img src="uploads/seckill_3.jpg" alt=""><b>热卖</b><div><strong>¥79</strong><br><del>¥118</del></div></li></ul></div></div><!-- 广告推销 --><div class="gg"><img src="uploads/banner_bg.jpg" alt="" width="100%"><div class="gg1"><ul><li class="left"><img src="uploads/banner_1.jpg" alt=""></li><li class="right"><img src="uploads/banner_2.jpg" alt=""></li><li class="right"><img src="uploads/banner_3.jpg" alt=""></li></ul></div></div><!-- 图片来了 --><div class="le"><ul><li><a href="#"><img src="uploads/major_1.jpg"></a><a href="#"><img src="uploads/major_2.jpg"></a><a href="#"><img src="uploads/major_3.jpg"></a></li><li><a href="#"><img src="uploads/major_4.jpg"></a><a href="#"><img src="uploads/major_5.jpg"></a> </li><li><a href="#"><img src="uploads/major_6.jpg"></a><a href="#"><img src="uploads/major_7.jpg"></a></li></ul></div><!-- 小广告 --><div class="xg"><div><a href=""><img src="uploads/advert_4.jpg" alt=""></a></div></div><!-- 草泥马臭嗨 --><div class="ch"><ul class="clearfix"><li><a href="">猜你喜欢</a></li><li><span></span><a href="">登陆更精彩</a></li></ul></div><!-- 产品区域 --><div class="qy clearfix"><ul class="clearfix"><li><a href=""><img src="uploads/item_1.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li><li><a href=""><img src="uploads/item_2.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li><li><a href=""><img src="uploads/item_3.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li><li><a href=""><img src="uploads/item_4.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li><li><a href=""><img src="uploads/item_5.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li><li><a href=""><img src="uploads/item_6.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li><li><a href=""><img src="uploads/item_7.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li><li><a href=""><img src="uploads/item_8.jpg" alt=""><p>曼秀雷敦(Mentholatum)控油抗痘洁面乳150ml(男士洗面奶 洁面 控油)</p></a><span class="left">¥25.20</span><span class="right qy1">看相似</span></li></ul></div><!-- 底部 --><div class="bgcolor"><div class="db"><div class="db1"><a href="">点击加载更多</a></div><div class="pl"><ul><li><a href="">登陆</a></li><li><a href="">注册</a></li><li><a href="">反馈</a></li><li><a href="">回到顶部</a></li></ul></div><!-- 显示图标 --><div class="tt1"><a href="#"><i></i>客户端</a><a href="#"><i></i>触屏版</a><a href="#"><i></i>电脑版</a></div></div></div><!-- 收尾 --><div class="sw"><a href="#"><img src="img/index-icon.png" alt=""></a><a href="#"><img src="img/sort-icon.png" alt=""></a><a href="#"><img src="img/618-icon.png" alt=""></a><a href="#"><img src="img/center-icon.png" alt=""></a><a href="#"><img src="img/cart-icon.png" alt=""></a></div></div>
</body>
base.css代码如下:
body,p,dl,ul,ol,h1,h2,h3,h4,h5,h6{margin: 0;padding: 0;list-style: none;color: black;font-size: 14px;font-family: "微软雅黑";
}
a{display:block;text-decoration: none;color: black;
}
img,input{border: 0 none;outline-style: none;margin: 0;padding: 0;vertical-align: middle;
}
.left{float:left;
}
.right{float: right;
}
.clearfix::after{content: "";display:block;
}
.clearfix{zoom: 1;
}
index.css代码如下:
.xin{width: 100%;text-align: center;max-width: 640px;min-width: 320px;margin: 0 auto;
}
.nav{width: 100%;height: 40px;background-color: rgba(201, 21, 35, 1);padding: 0 60px 0 80px;box-sizing: border-box;position: fixed;z-index: 5;max-width:640px;min-width: 320px;
}
.nav .nav1{width: 60px;height: 30px;text-align: center;line-height: 30px;display: block;color: #ffffff;position: absolute;top: 5px;right: 0px;
}
.nav input{width: 100%;height: 30px;padding-left: 30px;margin-top: 5px;border-radius: 15px;box-sizing: border-box;
}
.nav .nav2{display: block;width: 55px;height: 30px;position: absolute;top: 9px;left: 8px;background:url(../img/jd-sprites.png) no-repeat 0px -110px;background-size: 200px 200px;
}
.nav .nav3{display: block;width: 20px;height: 20px;background: url(../img/jd-sprites.png) no-repeat -59px -110px;background-size: 200px 200px;position: absolute;top: 10px;left: 87px;
}
.tu{width: 100%;padding: 10px 0px;overflow: hidden;
}
.tu li{float: left;width: 25%;text-align: center;}
.tu div{font-size: 12px;margin: 10px 0;
}
.tu img{width: 40px;;
}
.guodu{width: 100%;height: 12px;background-color: #f5f5f5;
}
.ms{width: 100%;}
.ms li{float: left; }
.ms1{position: relative;
}
.ms ul{margin-left: 10px;overflow: hidden;
}
.ms2{width: 22px;height: 28px;background:url(../img/jd-sprites.png) no-repeat -81px -108px; background-size: 200px 200px;
}
.ms3{padding-top: 5px;padding-left: 5px;padding-right: 5px;
}
.ms3 a{color: red;
}
.ms4{padding-top: 5px;
}
.ms5{background-color: black;border-radius: 20%;color: #ffffff;
}
.ms6{position: absolute;top: 5px;right: 5px;margin-right: 5px;
}.hz{width: 100%;padding-bottom: 20px;}
.hz ul{margin-left: 10px;}
.hz ul img{width:110%;}
.hz li{float: left;width: 33.3%;text-align: center;padding: 0 10px;box-sizing: border-box;position: relative;}
.hz b{font-size: 12px;color: #fff;background-color: orange;padding: 10px 5px;border-radius: 20px;position: absolute;bottom: 30px;right: 5px;
}
.hz strong{color: brown;
}
.gg{width: 100%;position: relative;
}
.gg ul{width: 100%;}
.gg1{position: absolute;bottom: 0;left: 0;padding: 5px;
}
.gg li:nth-child(1){width: 50%;box-sizing: border-box;text-align: center;
}
.gg li:nth-child(1) img{width: 100%;
}
.gg li:nth-child(2){width: 50%;box-sizing: border-box;text-align: center;
}
.gg li:nth-child(2) img{width: 100%;
}
.gg li:nth-child(3) img{width: 100%;
}
.gg li:nth-child(3){width: 50%;box-sizing: border-box;text-align: center;
}
.gg img{width: 100%;
}.le{width: 100%;
}
.le ul{width: 100%;
}
.le li{float: left;width: 100%;
}
.le li:nth-child(1) a{display:block;float: left;width: 33.3%;
}
.le li:nth-child(1) a img{width: 100%;
}
.le li a{width:50%;display: block;float: left;
}
.le li a img{width: 100%;
}
.xg{width: 100%;background-color: #cccccc;
}
.xg div{width: 100%;
}
.xg div img{width: 100%;padding: 10px 10px;box-sizing: border-box;
}
.ch ul{padding: 10px 10px;
}
.ch li:nth-child(1){float: left;
}
.ch li:nth-child(2){float:right;position: relative;
}
.ch li:nth-child(2) span{display:block;width: 18px;height: 18px;background: pink url('../img/icon-login.png') no-repeat;background-size: 18px;position: absolute;left: -20px;top: 2px;border-radius: 9px;
}
.qy{width: 100%;
}
.qy ul{width: 100%;padding-top: 30px;overflow: hidden;
}
.qy li{float: left;width: 50%;padding: 10px;box-sizing: border-box;}
.qy li a {width: 100%;padding-bottom: 5px;border-bottom: 2px solid #666;}
.qy li a img{width: 100%;
}
.qy .qy1{display:block;border:1px solid #cccccc;margin-top: 5px;color:#000;
}
.qy span{margin-top: 5px;color: red;
}
.db{margin-top: 10px;width: 100%;background-color: #666;
}
.db1{width: 100%;
}
.db1 a{display: block;color: #000;font-size: 16px;text-align:center;border:1px solid #000000;border-left: 0;border-right: 0;line-height: 30px;
}
.pl li{float: left;width:25%;text-align: center;background-color: #666;border-bottom: 1px solid #000;
}
.pl li a{border-right:1px solid #000;margin: 5px 0;
}
.pl li:nth-child(4) a{border-right: 0;
}.tt1 {height: 80px;margin-bottom: 44px; background-color: #666;margin-bottom: 62px;
}.tt1 a {float: left;text-align: center;width: 33.33333%;position: relative;padding-top: 50px;color: #000;background-color:#666;
}
.tt1 a i {width: 33px;height: 33px;display: block;background: url('../img/jd-sprites.png') no-repeat -120px -70px;background-size: 200px 200px;position: absolute;top: 10px;left: 50%;transform: translateX(-50%);
}
.tt1 a:nth-child(2) i{background-position: -40px -70px;
}.tt1 a:nth-child(3) i{background-position: -80px -70px;
}
.sw{width: 100%;height: 44px;position: fixed;bottom: 0;background-color: #fff;padding: 0 0 0 10px;box-sizing:border-box;max-width: 640px;min-width: 320px;
}
.sw a {float: left;width: 20%;height: 100%;
}.sw a img {height: 100%;
}