- index.html
- index.css
- reset.css
- header.css
- nav.css
- miaosha.css
- recommend.css
- footer.css
HTML
<!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">
<title>Document</title>
<link rel="stylesheet" href="static/icon-font/iconfont.css">
<link rel="stylesheet" href="static/css/index.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/miaosha.css">
<link rel="stylesheet" href="static/css/recommed.css">
</head>
<body>
<!-- header -->
<header class="header">
<!-- menu icon -->
<div class="menu iconfont icon-menu"></div>
<!-- search bar -->
<div class="search">
<div class="logo">JD</div>
<div class="zoom iconfont icon-search"></div>
<input type="text" class="words" value="移动硬盘500G" name="" id="">
</div>
<!-- login button -->
<a href="" class="login">登录</a>
</header>
<!-- main -->
<main class="main">
<!-- main nav area -->
<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="">充值缴费</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-7.png" alt=""></a>
<a href="">9.9元拼</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="">领金贴</a>
</li>
<li>
<a href=""><img src="static/images/dh/nav-10.png" alt=""></a>
<a href="">PLUS会员</a>
</li>
</ul>
<!-- 秒杀区 -->
<div class="miaosha">
<!-- 秒杀区顶部 -->
<div class="miaosha-top">
<div class="left">
<div class="title">京东秒杀</div>
<div class="venue-combo">
<div class="venue-hour">20点场</div>
<div class="venue-time">01:39:28</div>
</div>
</div>
<div class="right">更多秒杀 <span> > </span></div>
</div>
<!-- 秒杀区主体 -->
<ul class="miaosha-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">338</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">338</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">338</div>
</li>
</ul>
</div>
<!-- 推荐区 -->
<ul class="recommend">
<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-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-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-2.webp" alt=""></a>
<p>商品介绍哈哈</p>
<div class="price">
<div class="iconfont icon-rmb">138</div>
<div>看相似</div>
</div>
</li>
</ul>
</main>
<footer class="footer">
<div>
<div class="iconfont icon-home"></div>
<div>首页</div>
</div>
<div>
<div class="iconfont icon-layers"></div>
<div>分类</div>
</div>
<div>
<div class="iconfont icon-xiangmu"></div>
<div>京喜</div>
</div>
<div>
<div class="iconfont icon-shopping-cart"></div>
<div>购物车</div>
</div>
<div>
<div class="iconfont icon-user"></div>
<div>未登录</div>
</div>
</footer>
</body>
</html>
index.css
/* @import url("reset.css"); */
@import "reset.css";
.header {
background-color: #e43130;
color: #fff;
height: 4.4rem;
/* 固定header在顶部 */
position: fixed;
top: 0;
left: 0;
right: 0;
/* 保证在最前端 */
z-index: 1000;
}
.footer {
background-color: rgb(255, 250, 250);
color: rgb(131, 129, 129);
height: 4.4rem;
/* 固定header在顶部 */
position: fixed;
bottom: 0;
left: 0;
right: 0;
/* 保证在最前端 */
z-index: 100;
}
.main {
/* 主题绝对定位,防止被header, footer遮挡 */
position: absolute;
top: 4.4rem;
left: 0;
right: 0;
/* 无效, 不知道为毛 */
/* bottom: 4.4rem; */
/* main添加padding-bottom 无法解决底部遮挡,需要推荐部分添加 */
/* padding-bottom: 50rem; */
/* 保证在最前端 */
z-index: 100;
}
reset.css
* {
margin: 0;
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;
}
}
header.css
.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;
background-color: #fff;
border-radius: 10rem;
display: flex;
}
.header .search .logo {
color: red;
text-align: center;
line-height: 2rem;
flex-basis: 4rem;
}
.header .search .zoom {
color: #ccc;
border-left: 1px solid;
text-align: center;
line-height: 2rem;
flex-basis: 4rem;
}
.header .search .words {
/* flex: auto; */
font-size: 1.2rem;
color: #aaa;
border: none;
outline: none;
}
nav.css
/* images */
.main .nav img {
height: 4rem;
width: 4rem;
}
/* nav area */
.main .nav {
/* border: 1px solid white; */
display: flex;
flex-flow: row wrap;
padding: 1rem;
}
.main .nav li {
flex: 1 1 20%;
display: flex;
flex-flow: column nowrap;
align-items: center;
/* padding: 1rem; */
}
miaosha.css
.main .miaosha {
background-color: #fff;
margin: 1rem 2.2rem;
padding: 1rem;
border: 1px solid #fff;
border-radius: 2rem;
/* display: flex; */
/* flex-flow: row nowrap; */
}
.main .miaosha .miaosha-top {
display: flex;
justify-content: space-between;
margin-bottom: 2rem;
}
.main .miaosha .miaosha-top .left {
display: flex;
}
.main .miaosha .miaosha-top .left .venue-combo {
display: flex;
/* justify-content: center;
align-items: center; */
}
.main .miaosha .miaosha-top .left .venue-combo .venue-hour {
color: red;
margin: 0 1rem;
}
.main .miaosha .miaosha-top .left .venue-combo .venue-time {
color: white;
background-color: red;
margin: 0 1rem;
}
.main .miaosha .miaosha-top .right {
color: red;
}
.main .miaosha .miaosha-top .right > span {
color: white;
background-color: red;
border-radius: 5rem;
}
.main .miaosha .miaosha-body {
display: flex;
flex-grow: row nowrap;
justify-content: space-between;
}
.main .miaosha .miaosha-body .item {
display: flex;
flex-flow: column nowrap;
align-items: center;
/* text-align: center; */
}
.main .miaosha .miaosha-body .item img {
height: 8rem;
width: 8rem;
}
.main .miaosha .miaosha-body .item div:first-of-type {
color: red;
font-weight: bolder;
}
.main .miaosha .miaosha-body .item div:last-of-type {
color: #666;
text-decoration: line-through;
text-decoration-color: #666;
}
recommend.css
.main .recommend {
display: flex;
flex-flow: row wrap;
justify-content: center;
/* border: 1px solid; */
/* margin-bottom 无法解决底部遮挡 */
/* margin-bottom: 20rem; */
padding-bottom: 4.4rem;
}
.main .recommend .item {
display: flex;
flex-flow: column nowrap;
/* ************ */
/* flex-basis: 50%; */
flex-basis: calc(50% - 3rem);
padding: 1rem;
background-color: #fff;
margin-left: 1rem;
margin-bottom: 1rem;
/* 图没了价格也在item 底部 */
justify-content: flex-end;
}
.main .recommend .item img {
width: 100%;
height: 100%;
}
/* 右边商品单独设置外边距 even / 2n */
.main .recommend .item:nth-of-type(even) {
margin-right: 1rem;
}
.main .recommend .item .price {
display: flex;
justify-content: space-between;
}
.main .recommend .item .price div:first-of-type {
color: red;
font-weight: bolder;
font-size: x-large;
}
.main .recommend .item .price div:last-of-type {
background-color: #7675752c;
font-weight: lighter;
font-size: smaller;
border-radius: 1rem;
}
footer.css
.footer {
display: flex;
flex-flow: row nowrap;
justify-content: space-around;
align-items: center;
}
.footer > div {
display: flex;
flex-flow: column nowrap;
}
.footer > div .iconfont {
font-size: 2rem;
text-align: center;
}
.footer > div > div:last-of-type {
font-size: 1rem;
}
.footer > div:hover {
cursor: pointer;
}