<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="static/css/index.css" />
<link rel="stylesheet" href="static/icon-font/iconfont.css" />
<link rel="stylesheet" href="static/css/header.css" />
<link rel="stylesheet" href="static/css/footer.css" />
<link rel="stylesheet" href="static/css/nav.css" />
<link rel="stylesheet" href="static/css/ms.css" />
<link rel="stylesheet" href="static/css/tj.css" />
<title>页眉+页脚+主导航+秒杀区+推荐商品列表区</title>
</head>
<body>
<div class="header">
<!-- 菜单 -->
<div class="menu iconfont icon-menu"></div>
<!-- 搜索框 -->
<div class="search">
<div class="logo">JD</div>
<div class="zoom iconfont icon-search"></div>
<input type="text" class="words" value="移动硬盘5000g" id="" />
</div>
<!-- 登录按钮 -->
<a href="" class="login">登录</a>
</div>
<!-- 主体 -->
<div class="main">
<!-- 主导航区 -->
<ul class="nav">
<li>
<a href=""><img src="static/images/dh/nav-1.png" alt="" /></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-2.png" alt="" /></a>
<a href="">数码电器</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-3.png" alt="" /></a>
<a href="">京东服饰</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-4.png" alt="" /></a>
<a href="">京东生鲜</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-5.png" alt="" /></a>
<a href="">充值缴费</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-6.png" alt="" /></a>
<a href="">9.9元拼</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-7.png" alt="" /></a>
<a href="">领劵</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-8.png" alt="" /></a>
<a href="">领津贴</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-9.png" alt="" /></a>
<a href="">PLUS会员</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-10.png" alt="" /></a>
<a href="">数码电器</a>
</li>
</ul>
<!-- 秒杀区 -->
<div class="ms">
<div class="ms-top">
<div class="left">
<div class="title">京东秒杀</div>
<div class="notice">
<div class="tips">20点专场</div>
<div class="time">01:40:33</div>
</div>
</div>
<div class="right">更多秒杀</div>
</div>
<!-- 秒杀主体区 -->
<ul class="ms-body">
<li class="item">
<a href=""><img src="static/images/ms/ms-1.jpg" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">558</div>
</li>
<li class="item">
<a href=""><img src="static/images/ms/ms-2.jpg" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">558</div>
</li>
<li class="item">
<a href=""><img src="static/images/ms/ms-3.jpg" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">558</div>
</li>
<li class="item">
<a href=""><img src="static/images/ms/ms-4.jpg" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">558</div>
</li>
</ul>
</div>
<!-- 推荐商品列表区 -->
<ul class="tj">
<li class="item">
<a href=""><img src="static/images/sp/sp-1.webp" alt="" /></a>
<p>
商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍
</p>
<div class="price">
<div class="iconfont icon-rmb">138</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="static/images/sp/sp-2.webp" alt="" /></a>
<p>
商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍
</p>
<div class="price">
<div class="iconfont icon-rmb">138</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="static/images/sp/sp-3.webp" alt="" /></a>
<p>
商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍
</p>
<div class="price">
<div class="iconfont icon-rmb">138</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="static/images/sp/sp-4.webp" alt="" /></a>
<p>
商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍
</p>
<div class="price">
<div class="iconfont icon-rmb">138</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="static/images/sp/sp-5.webp" alt="" /></a>
<p>
商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍
</p>
<div class="price">
<div class="iconfont icon-rmb">138</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="static/images/sp/sp-6.webp" alt="" /></a>
<p>
商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍商品介绍
</p>
<div class="price">
<div class="iconfont icon-rmb">138</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-home"></div>
<span>分类</span>
</div>
<div>
<div class="iconfont icon-home"></div>
<span>京喜</span>
</div>
<div>
<div class="iconfont icon-home"></div>
<span>购物车</span>
</div>
<div>
<div class="iconfont icon-home"></div>
<span>未登录</span>
</div>
</div>
</body>
</html>
reset.css
* {
margin: 0px;
padding: 0;
box-sizing: border-box;
}
li {
/* 去掉前面的点 */
list-style: none;
}
a {
/* 去掉下划线 */
text-decoration: none;
color: #7b7b7b;
}
body {
background-color: #f6f6f6;
}
html {
font-size: 10px;
}
body {
font-size: 1.6rem;
}
@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;
}
}
index.css
/* @import url("reset.css"); */
@import "reset.css";
.header {
background-color: #e43130;
color: #fff;
height: 4.4rem;
/* 固定定位 */
position: fixed;
left: 0;
top: 0;
right: 0;
/* 保证他始终在视口的最前面 */
z-index: 100;
}
/* 主体绝对定位 */
.main {
position: absolute;
top: 4.4rem;
left: 0;
right: 0;
bottom: 4.4rem;
}
.footer {
background-color: #eee;
color: #fff;
height: 4.4rem;
/* 固定定位 */
position: fixed;
left: 0;
bottom: 0;
right: 0;
z-index: 100;
}
footer.css
.footer {
display: flex;
justify-content: space-around;
align-items: center;
color: #666;
}
.footer > div {
display: flex;
flex-flow: column nowrap;
/* 主轴垂直 交叉轴水平 */
align-items: center;
}
.footer > div .iconfont {
font-size: 2rem;
}
.footer > div > span {
font-size: 1rem;
}
.footer > div:hover {
cursor: pointer;
}
header.css
/* 使用一个类作为入口,后面可以使用class或伪类来获取内部的每一个元素。 */
.header {
display: flex;
flex-flow: row nowrap;
align-items: center;
}
.header .menu {
flex: 1;
/* 行内元素 文本居中 */
text-align: center;
font-size: 2.5rem;
}
.header .login {
flex: 1;
color: white;
text-align: center;
}
.header .search {
flex: 6;
padding: 0.5rem;
background-color: #fff;
/* 圆角 */
border-radius: 3rem;
display: flex;
}
.header .search .logo {
color: #e43130;
font-size: 2rem;
flex: 0 1 4rem;
text-align: center;
line-height: 2rem;
}
.header .search .zoom {
color: #ccc;
flex: 0 1 4rem;
text-align: center;
/* 垂直居中 */
line-height: 2rem;
border-left: 1px solid;
}
.header .search .words {
flex: auto;
border: none;
outline: none;
color: #aaa;
}
nav.css
/* 主导航区样式 */
/* 图片 */
.main nav img {
height: 4rem;
width: 4rem;
}
/* 导航区 */
.main .nav {
/* border: 1px solid #000; */
padding: 1rem;
display: flex;
/* 转为多行容器 */
flex-flow: row wrap;
}
.main .nav li {
flex-grow: 1;
flex-shrink: 0;
flex-basis: 20%;
/* border: 1px solid #000; */
/* flex: 1 1 20%; */
display: flex;
flex-flow: column nowrap;
align-items: center;
}
tj.css
.main .tj {
font-size: 1.1rem;
color: #555;
display: flex;
/* 当前一行只显示两个 所以转为多行容器 允许换行 */
flex-flow: row wrap;
justify-content: center;
}
.main .tj .item {
flex-basis: calc(50% - 3rem);
padding: 1rem;
background-color: #fff;
display: flex;
flex-flow: column nowrap;
/* 添加外边距 */
margin-left: 1rem;
margin-bottom: 1rem;
border-radius: 1rem;
}
.main .th .item:nth-of-type(2n) {
margin-right: 1rem;
}
.main .tj .item img {
width: 100%;
height: 100%;
}
.main .tj .item .price {
display: flex;
justify-content: space-between;
}
.main .tj .item .price div:first-of-type {
color: red;
font-weight: bolder;
}
.main .tj .item .price div:last-of-type {
background-color: #f6f6f6;
padding: 0.2rem 1rem;
border-radius: 1rem;
color: #666;
}