效果图
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="css/jd.css">
<link rel="stylesheet" href="font/iconfont.css">
</head>
<body>
<header>
<div class="menu iconfont icon-caidan"></div>
<div class="search">
<div class="logo">JD</div>
<div class="zoom iconfont icon-sousuo"></div>
<input type="text" class="words" value="鼠标">
</div>
<a href="" class="login">登录</a>
</header>
<main>
<ul class="nav">
<li>
<a href=""><img src="images/dh/nav-1.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-2.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-3.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-4.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-5.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-6.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-7.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-8.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="images/dh/nav-9.png" alt=""></a>
<a href="">京东超市</a>
</li>
<li>
<a href=""><img src="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="notic">
<div class="tips">22点专场</div>
<div class="time">01:11:22</div>
</div>
</div>
<div class="right"><a href="">更多秒杀</a></div>
</div>
<ul class="ms-body">
<li class="item">
<a href=""><img src="images/ms/ms-1.jpg" alt=""></a>
<div>¥338</div>
<div>¥558</div>
</li>
<li class="item">
<a href=""><img src="images/ms/ms-2.jpg" alt=""></a>
<div>¥338</div>
<div>¥558</div>
</li>
<li class="item">
<a href=""><img src="images/ms/ms-3.jpg" alt=""></a>
<div>¥338</div>
<div>¥558</div>
</li>
<li class="item">
<a href=""><img src="images/ms/ms-4.jpg" alt=""></a>
<div>¥338</div>
<div>¥558</div>
</li>
</ul>
</div>
<h3 class="title">猜你喜欢</h3>
<ul class="tj">
<li class="item">
<a href=""><img src="images/sp/sp-1.webp" alt=""></a>
<a href="" class="ttitle">商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题</a>
<div class="price">
<div>¥203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="images/sp/sp-2.webp" alt=""></a>
<a href="" class="title">商品介绍</a>
<div class="price">
<div>¥203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="images/sp/sp-3.webp" alt=""></a>
<a href="" class="title">商品介绍</a>
<div class="price">
<div>¥203</div>
<div>看相似</div>
</div>
</li>
<li class="item">
<a href=""><img src="images/sp/sp-4.webp" alt=""></a>
<a href="" class="title">商品介绍</a>
<div class="price">
<div>¥203</div>
<div>看相似</div>
</div>
</li>
</ul>
</main>
<footer>
<div>
<div class="iconfont icon-shouye"></div>
<a href="">主页</a>
</div>
<div>
<div class="iconfont icon-fenlei"></div>
<a href="">分类</a>
</div>
<div>
<div class="iconfont icon-gouwuche"></div>
<a href="">购物车</a>
</div>
<div>
<div class="iconfont icon-shebei
icon-iconfonticon-shebei"></div>
<a href="">惊喜</a>
</div>
<div>
<div class="iconfont icon-yonghu"></div>
<a href="">未登录</a>
</div>
</footer>
</body>
</html>
css代码
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #f6f6f6;
}
li {
list-style: none;
}
a {
text-decoration: none;
outline: none;
}
html {
font-size: 10px;
}
header {
height: 4.4rem;
color: white;
background-color: #e43130;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
align-items: center;
font-size: 1.4rem;
justify-content: space-between;
}
footer {
height: 4.4rem;
background-color: #fff;
position: fixed;
left: 0;
right: 0;
bottom: 0;
box-shadow: 0 0 3px #999;
z-index: 999;
display: flex;
justify-content: space-around;
align-items: center;
font-size: 1.4rem;
}
main {
min-height: 100em;
position: absolute;
top: 4.4rem;
bottom: 4.4rem;
left: 0;
right: 0;
font-size: 1.4rem;
}
header .menu,
header .login {
flex: 1;
color: white;
text-align: center;
}
header .menu {
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 .zoom {
color: #ccc;
flex: 0 1 4rem;
font-size: 2rem;
border-left: 1px solid;
text-align: center;
line-height: 2rem;
}
header .search .words {
flex: auto;
border: none;
outline: none;
color: #aaa;
}
main .nav {
padding: 1rem;
display: flex;
flex-flow: row wrap;
justify-content: space-between
}
main .nav a:last-of-type {
color: #666;
}
main .nav img {
width: 4rem;
height: 4rem;
}
main .nav li {
flex: 1 1 20%;
display: flex;
flex-flow: column nowrap;
align-items: center;
}
main .ms {
background-color: #fff;
padding: 1rem;
margin: 1rem 0;
}
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 .notic {
font-size: 1.1rem;
height: 2rem;
display: flex;
border: 1px solid #e43130;
border-radius: 2rem;
margin-left: 1rem;
justify-content: center;
align-items: center;
}
main .ms .ms-top .left .notic .tips {
background-color: #e43130;
color: white;
border-radius: 2rem;
padding: 0.3rem 0.5rem;
}
main .ms .ms-top .left .notic .time {
padding: 0.3rem 0.5rem;
}
main .ms .ms-top .right a {
color: #e43130;
}
main .ms .ms-body {
display: flex;
justify-content: space-between;
overflow: hidden;
}
main .ms .ms-body img {
width: 12rem;
height: 12rem;
}
main .ms .ms-body .item {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
}
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 {
color: #555;
height: 4rem;
text-align: center;
}
main .tj {
display: flex;
flex-wrap: wrap;
}
main .tj .item {
flex: 1 1 calc(50% - 2rem);
display: flex;
flex-flow: column nowrap;
background-color: #fff;
margin-left: 1rem;
margin-bottom: 1rem;
padding-bottom: 1rem;
border-radius: 1rem;
}
main .tj .item img {
width: 100%;
height: 100%;
}
main .tj .item .ttitle {
color: #a1a1a1;
overflow: hidden;
text-overflow: ellipsis;
margin: .2rem 0;
word-break: break-all;
}
main .tj .item .price {
display: flex;
justify-content: space-between;
}
main .tj .item .price div:first-of-type {
color: #e43130;
}
main .tj .item .price div:last-of-type {
color: #666;
background-color: #f6f6f6;
border-radius: 1rem;
padding: 0.2rem 1rem;
}
footer>div {
display: flex;
flex-flow: column nowrap;
align-items: center;
margin: .8rem 1rem;
}
footer>div>.iconfont {
font-size: 1.5rem;
color: #666;
}
footer>div>a {
color: #666;
font-size: 1rem;
}
@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;
}
}