示例图
代码实例
<!DOCTYPE html>
<html lang="zh-CN">
<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/icon-font/iconfont.css" />
<link rel="stylesheet" href="static/css/index.css" />
<title>Document</title>
</head>
<body>
<header>
<!-- 小导航图标 -->
<div class="menu iconfont icon-menu"></div>
<!-- 搜索框 -->
<div class="search">
<div class="logo">JD</div>
<div class="suosuo iconfont icon-search"></div>
<input type="text" class="word" value="蛋糕" />
</div>
<a href="" class="login">登陆</a>
</header>
<div class="main">
<div class="banner">
<img src="static/images/bg/banner1.jpg" alt="" />
</div>
<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-1.png" alt="" /></a>
<a href="">京东超市</a>
</li>
<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-1.png" alt="" /></a>
<a href="">京东超市</a>
</li>
<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-1.png" alt="" /></a>
<a href="">京东超市</a>
</li>
<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-1.png" alt="" /></a>
<a href="">京东超市</a>
</li>
<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-1.png" alt="" /></a>
<a href="">京东超市</a>
</li>
</ul>
<!-- 秒杀? -->
<div class="ms">
<div class="mstop">
<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>
<ul class="miaoshi">
<li class="neir">
<a href="#"><img src="static/images/ms/ms-1.jpg" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">588</div>
</li>
<li class="neir">
<a href="#"><img src="static/images/ms/ms-1.jpg" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">588</div>
</li>
<li class="neir">
<a href="#"><img src="static/images/ms/ms-1.jpg" alt="" /></a>
<div class="iconfont icon-rmb">338</div>
<div class="iconfont icon-rmb">588</div>
</li>
</ul>
</div>
<div class="title">推荐商品</div>
<ul class="tj">
<li class="sp">
<a href="#"><img src="static/images/sp/sp-1.webp" alt="" /></a>
<p>这里是一个商品的介绍信息显示地方</p>
<div class="xs">
<div class="iconfont icon-rmb">100</div>
<div>看相似</div>
</div>
</li>
<li class="sp">
<a href="#"><img src="static/images/sp/sp-1.webp" alt="" /></a>
<p>这里是一个商品的介绍信息显示地方</p>
<div class="xs">
<div class="iconfont icon-rmb">100</div>
<div>看相似</div>
</div>
</li>
<li class="sp">
<a href="#"><img src="static/images/sp/sp-1.webp" alt="" /></a>
<p>这里是一个商品的介绍信息显示地方</p>
<div class="xs">
<div class="iconfont icon-rmb">100</div>
<div>看相似</div>
</div>
</li>
<li class="sp">
<a href="#"><img src="static/images/sp/sp-1.webp" alt="" /></a>
<p>这里是一个商品的介绍信息显示地方</p>
<div class="xs">
<div class="iconfont icon-rmb">100</div>
<div>看相似</div>
</div>
</li>
</ul>
</div>
<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-shopping-cart"></div>
<span>购物车</span>
</div>
<div>
<div class="iconfont icon-user"></div>
<span>我的</span>
</div>
</footer>
</body>
</html>
CSS部分
/* 导入公共初始化样式表 */
@import "reset.css";
/* 头部开始 */
header {
display: flex;
align-items: center;
background-color: #e43130;
color: white;
height: 4.4rem;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
font-size: 1.4rem;
}
header .menu {
text-align: center;
flex: 1;
font-size: 2.5rem;
}
header .search {
flex: 6;
padding: 0.5rem;
background-color: #fff;
border-radius: 3rem;
display: flex;
}
header .search .logo {
color: #e43130;
flex: 0 1 4rem;
font-size: 2rem;
text-align: center;
line-height: 2rem;
}
header .search .suosuo {
color: #ccc;
flex: 0 1 2em;
border-left: 1px solid;
text-align: center;
line-height: 2rem;
}
header .search .word {
flex: auto;
border: none;
outline: none;
color: #aaa;
}
header .login {
color: #fff;
text-align: center;
flex: 1;
}
/* 头部结束 */
/* 内容区暂定 */
.main {
position: absolute;
top: 4.4rem;
bottom: 4.4rem;
left: 0;
right: 0;
font-size: 1.4rem;
}
.banner {
margin: 1rem;
}
.banner img {
height: 15rem;
width: auto;
border-radius: 2rem;
}
.main .nav {
padding: 1rem;
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
.main .nav li {
flex: 1 1 20%;
display: flex;
flex-flow: column nowrap;
align-items: center;
}
.main .nav img {
height: 4rem;
width: 4rem;
}
/* 秒杀 */
.ms {
background-color: #fff;
padding: 1rem;
margin: 1rem;
border-radius: 2rem;
}
.mstop {
font-size: 1.3rem;
height: 3rem;
display: flex;
justify-content: space-between;
}
.left {
display: flex;
}
.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;
}
.tips {
background-color: #e43130;
color: #fff;
border-radius: 2rem;
padding: 0.3rem 0.5rem;
}
.time {
padding: 0.3rem 0.5rem;
}
.right {
color: #e43130;
}
.miaoshi {
display: flex;
justify-content: space-between;
}
.neir {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.neir img {
height: 12rem;
width: 12rem;
}
.main .ms .neir div:first-of-type {
color: #e43130;
font-weight: bolder;
}
.main .ms .neir div:last-of-type {
color: #666666;
text-decoration: line-through;
text-decoration-color: #666666;
}
/* 商品? */
.title {
height: 4rem;
color: #555;
font-weight: 500;
text-align: center;
}
.tj {
font-size: 1rem;
display: flex;
flex-wrap: wrap;
}
.sp {
flex: 1 1 calc(50% - 2rem);
background-color: #fff;
overflow: hidden;
display: flex;
flex-flow: column nowrap;
padding: 1rem;
margin-left: 1rem;
margin-bottom: 1rem;
padding-bottom: 1rem;
border-radius: 1rem;
}
.sp img {
width: 100%;
height: 100%;
}
.xs {
display: flex;
justify-content: space-between;
}
.xs div:first-of-type {
color: #e43130;
}
.xs div:last-of-type {
color: #666;
background-color: #f6f6f6;
border-radius: 1rem;
padding: 0.2rem 1rem;
}
/* 底部开始 */
footer {
display: flex;
justify-content: space-around;
align-items: center;
color: #666;
background-color: #fafafa;
box-shadow: 0 0 3px #999;
height: 4.4rem;
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 100;
font-size: 1.6rem;
}
footer div {
display: flex;
flex-flow: column nowrap;
align-items: center;
}
footer div .iconfont {
font-size: 2.4rem;
}
footer div .span {
font-size: 1rem;
}
/* 底部结束 */