尝试仿作“京东商城”手机网站
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="/1223/static/css/iconfont.css" />
<link rel="stylesheet" href="/1223/static/css/icon-font/iconfont.css" />
<!-- 首页 -->
<link rel="stylesheet" href="/1223/static/css/index.css" />
<!-- 页眉区 -->
<link rel="stylesheet" href="/1223/static/css/header.css" />
<!-- 导航 -->
<link rel="stylesheet" href="/1223/static/css/nav.css" />
<!-- 秒杀 -->
<link rel="stylesheet" href="/1223/static/css/ms.css" />
<!-- 猜你喜欢 -->
<link rel="stylesheet" href="/1223/static/css/tj.css" />
<!-- 页脚 -->
<link rel="stylesheet" href="/1223/static/css/footer.css" />
</head>
<body>
<!-- 页眉 -->
<div class="header">
<!-- 字体图标 -->
<div class="menu iconfont icon-V"></div>
<!-- 搜索框 -->
<div class="search">
<div class="logo">JD</div>
<div class="zoom iconfont icon-viewlarger"></div>
<input class="words" type="text" value="蓝牙鼠标" />
</div>
<!-- 登录按钮 -->
<a href="" class="login">登录</a>
</div>
<!-- 主体 -->
<div class="main">
<div>
<img class="pic-1" src="/1223/static/images/bg/banner.jpg" alt="" />
</div>
<!-- 主导航区 -->
<ul class="nav">
<li>
<a href=""
><img src="/1223/static/images/shangpin (1).png" alt=""
/></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (2).png" alt=""
/></a>
<a href="">数码超市</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (3).png" alt=""
/></a>
<a href="">京东服饰</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (4).png" alt=""
/></a>
<a href="">京东生鲜</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (5).png" alt=""
/></a>
<a href="">充值缴费</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (6).png" alt=""
/></a>
<a href="">9.9元拼</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (7).png" alt=""
/></a>
<a href="">领券</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (8).png" alt=""
/></a>
<a href="">借钱</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (9).png" alt=""
/></a>
<a href="">京东到家</a>
</li>
<li>
<a href=""
><img src="/1223/static/images/shangpin (10).png" alt=""
/></a>
<a href="">PLUS会员</a>
</li>
</ul>
<!-- 秒杀区 -->
<div class="ms">
<div class="ms-top">
<div class="left">
<div class="title">京东秒杀</div>
<div class="notice">
<div class="tips">22点专场</div>
<div class="time">01:11:22</div>
</div>
</div>
<div class="right">更多秒杀</div>
</div>
<div class="ms-body">
<li class="item">
<a href=""><img src="/1223/static/images/ms- (1).png" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">558</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/ms- (2).png" alt="" /></a>
<div class="iconfont icon-rmb">738</div>
<div class="iconfont icon-rmb">858</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/ms- (3).png" alt="" /></a>
<div class="iconfont icon-rmb">6738</div>
<div class="iconfont icon-rmb">8858</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/ms- (4).png" alt="" /></a>
<div class="iconfont icon-rmb">4568</div>
<div class="iconfont icon-rmb">5588</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/ms- (5).png" alt="" /></a>
<div class="iconfont icon-rmb">1338</div>
<div class="iconfont icon-rmb">2558</div>
</li>
</div>
</div>
<!-- 猜你喜欢 -->
<h3 class="title">猜你喜欢</h3>
<ul class="tj">
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-1.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
2、完成网站所有静态页面布局;重点:弹性布局与网格布局;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-2.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
2、完成网站所有静态页面布局;重点:弹性布局与网格布局;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-3.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
2、完成网站所有静态页面布局;重点:弹性布局与网格布局;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-4.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
2、完成网站所有静态页面布局;重点:弹性布局与网格布局;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-5.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
2、完成网站所有静态页面布局;重点:弹性布局与网格布局;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-6.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
2、完成网站所有静态页面布局;重点:弹性布局与网格布局;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-7.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
2、完成网站所有静态页面布局;重点:弹性布局与网格布局;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="/1223/static/images/sp/sp-8.webp" alt="" /></a>
<p>
php中文网第十四期前端开发部分学习目标:1、HTML5+CSS3基础知识与实战;
</p>
<div class="price">
<div class="iconfont icon-rmb">203</div>
<div>看相似</div>
</div>
</li>
</ul>
</div>
<!-- 页脚 -->
<div class="footer">
<div>
<div class="iconfont icon-home"></div>
<span>主页</span>
</div>
<div>
<div class="iconfont icon-layers"></div>
<span>分类</span>
</div>
<div>
<div class="iconfont icon-kehuguanli"></div>
<span>惊喜</span>
</div>
<div>
<div class="iconfont icon-shopping-cart"></div>
<span>购物车</span>
</div>
<div>
<div class="iconfont icon-user"></div>
<span>未登录</span>
</div>
</div>
</body>
</html>
css部分
@import "/1223/static/css/reset.css";
/* 页眉 */
.header {
background-color: #e43130;
color: white;
height: 3.5rem;
font-size: 1.4rem;
/* 固定定位 */
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
/* 页脚 */
.footer {
color: #666;
background-color: #fafafa;
box-shadow: 0 0 3px #999;
height: 4.4rem;
font-size: 1.4rem;
/* 固定定位 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 100;
}
/* 主体 */
.main {
/* 绝对定位 */
position: absolute;
top: 4.4rem;
bottom: 4.4rem;
left: 0;
right: 0;
font-size: 1.4rem;
/* height: 100rem; */
/* background-color: yellow; */
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
li {
list-style: none;
}
a {
columns: #7b7b7b;
text-decoration: none;
}
body {
background-color: #f6f6f6;
}
html {
font-size: 10px;
}
/* 媒体查询 */
@media screen and (min-width: 480px) {
html {
font-size: 12px;
}
}
@media screen and (min-width: 640px) {
html {
font-size: 14px;
}
}
@media screen and (min-width: 720px) {
html {
font-size: 16px;
}
}
.header {
display: flex;
align-items: center;
}
/* 页眉中三个部分的比例 1:6:1 */
.header .login {
flex: 1;
color: #fff;
text-align: center;
}
.header .menu {
flex: 1;
text-align: center;
font-size: 2rem;
}
.header .search {
flex: 6;
padding: 0.3rem 0.5rem;
background-color: #fff;
border-radius: 3rem;
display: flex;
}
.header .search .logo {
color: #e34130;
flex: 0 1 3rem;
font-size: 1.5rem;
/* padding: 0 0.2rem; */
/* 水平垂直居中 */
text-align: center;
/* align-items: center; */
line-height: 2rem;
}
.header .search .zoom {
color: #cccccc;
flex: 0 1 4 #ccc;
font-size: 2rem;
/* padding: 0 0.2rem; */
border-left: 1px solid;
/* 水平垂直居中 */
text-align: center;
/* align-items: center; */
line-height: 2rem;
}
/* 搜索文本框 */
.header .search .words {
flex: auto;
border: none;
outline: none;
font-size: 1.2rem;
color: #aaaaaa;
}
.footer {
display: flex;
justify-content: space-around;
padding-top: 0.5rem;
}
.footer > div {
display: flex;
flex-flow: column nowrap;
align-items: center;
}
.footer > div > .iconfont {
font-size: 2rem;
}
.footer > div > span {
font-size: 1rem;
}
.main .nav {
padding: 1rem;
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
.main .nav img {
height: 4rem;
width: 4rem;
}
.main .nav li {
flex: 1 1 20%;
display: flex;
flex-flow: column nowrap;
align-items: center;
}
.main a {
font-size: 1rem;
}
.main .pic-1 {
width: 100%;
border-radius: 10rem;
padding: 0 1rem;
}
/* 秒杀 */
.main .ms {
background-color: rgb(230, 227, 224);
padding: 1rem;
margin: 1rem 0;
border-radius: 2rem;
}
.main .ms .ms-top {
font-size: 1.3rem;
height: 3rem;
display: flex;
justify-content: space-between;
}
.main .ms .ms-top .left {
display: flex;
}
.main .ms .ms-top .left .notice {
font-size: 1.1rem;
height: 2rem;
border: 1px solid #e43130;
border-radius: 2rem;
margin-left: 1rem;
display: flex;
justify-content: center;
align-items: center;
}
.main .ms .ms-top .left .notice .tips {
background-color: #e43130;
color: #fff;
border-radius: 2rem;
padding: 0.3rem 0.5rem;
}
.main .ms .ms-top .left .notice .time {
padding: 0.3rem 0.5rem;
}
.main .ms .ms-top .right {
color: #e43130;
}
/* 主体区 */
.main .ms .ms-body {
background-color: #fff;
border-radius: 1rem;
display: flex;
justify-content: space-between;
/* justify-content: center; */
}
.main .ms .ms-body img {
height: 7rem;
width: 7rem;
}
.main .ms .ms-body .item div:first-of-type {
color: #e43130;
font-weight: bolder;
}
.main .ms .ms-body .item div:last-of-type {
color: #666;
text-decoration: line-through;
text-decoration-color: #666;
}
.main .title {
height: 4rem;
color: #555555;
font-weight: 550;
text-align: center;
}
.main .tj {
font-size: 1rem;
display: flex;
flex-wrap: wrap;
}
.main .tj .item {
flex: 0 1 calc(50% - 2rem);
background-color: azure;
overflow: hidden;
display: flex;
flex-flow: column nowrap;
margin-left: 1rem;
margin-bottom: 1rem;
padding-bottom: 1rem;
border-radius: 1rem;
}
.main .tj .item img {
width: 100%;
height: 100%;
}
.main .tj .item {
padding: 1rem;
}
.main .tj .item .price {
display: flex;
justify-content: space-between;
}
.main .tj .item .price div:first-of-type {
color: brown;
}
.main .tj .item .price div:last-of-type {
color: rgb(78, 70, 70);
background-color: #f6f6f6;
border-radius: 1rem;
padding: 0.2rem 1rem;
}