京东app页面
- rest.css全局初始化文件,媒体查询文件
- 通过impoart公共文件
- @media screen and (min-width: 480px)— font-size: 12px;
- @media screen and (min-width: 640px)— font-size: 14px;
- @media screen and (min-width: 720px)— font-size: 16px;
- 通过媒体查询改变html文字大小,实现全局响应式
- header,footer文件单独书写引入,模块通用,使用用绝对定位,z-inde属性等排在最上层
页面效果
rest.css 全局代码实现
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
li {
list-style: none;
}
a {
color: #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;
}
}
@import "reset.css";
.header {
height: 2.5rem;
background-color: #c82519;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
.footer {
height: 2.5rem;
background-color: #ffffff;
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 100;
}
.main {
position: absolute;
top: 2.5rem;
left: 0;
right: 0;
bottom: 2.5rem;
}
/* ------------header头部------------------- */
.header {
display: flex;
align-items: center;
}
.header .menu {
color: white;
flex: 1;
text-align: center;
font-size: 1.5625rem;
}
.header .search {
flex: 6;
background-color: white;
border-radius: 0.9375rem;
display: flex;
align-items: center;
}
.header .search .jd {
color: #c82519;
flex: 0 1 2.5rem;
text-align: center;
font-size: 1.25rem;
}
.header .search .zoom {
color: #aaa;
border-left: 1px solid;
flex: 0 1 2.5rem;
text-align: center;
}
.header .search .words {
outline: none;
flex: auto;
border: none;
color: #aaa;
margin-right: 0.5rem;
}
.header .login {
color: white;
flex: 1;
text-align: center;
}
/* --------------尾部------------------------------------ */
.footer {
display: flex;
justify-content: space-around;
align-items: center;
}
.footer > div {
color: #8b8b8b;
text-align: center;
}
.footer > div > .iconfont {
font-size: 1.25rem;
}
.footer > div > span {
font-size: 0.625rem;
}
/* -------------------nav分类----------------------------- */
.nav {
padding: 0.625rem;
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
.nav > li {
flex: 1 1 20%;
display: flex;
flex-flow: column nowrap;
align-items: center;
}
.nav > li > a > img {
height: 2.5rem;
}
.nav > li > a {
font-size: 0.75rem;
}
/* ----------------秒杀----------------------------------- */
.main .ms {
padding: 0 0.625rem;
margin: 0.625rem;
background-color: white;
border-radius: 0.625rem;
}
.main .ms .ms-top {
display: flex;
justify-content: space-between;
align-content: center;
padding: 0.3125rem;
display: flex;
height: 1.875rem;
}
.main .ms .ms-top .ms-left {
display: flex;
align-content: center;
}
.main .ms .ms-top .ms-left .title {
padding-right: 1.25rem;
}
.main .ms .ms-top .ms-left .ms-sj {
color: #c82519;
}
.main .ms .ms-top .right {
color: #c82519;
}
.main .ms .ms-body {
display: flex;
overflow: auto;
}
.ms-body .item {
display: flex;
flex-flow: column nowrap;
text-align: center;
padding: 0.625rem 0;
}
.ms-body .item > a > img {
height: 100px;
width: 100px;
}
.ms-body .item .iconfont:first-of-type {
color: red;
}
.ms-body .item .iconfont:last-of-type {
text-decoration: line-through;
}
/* ----------------------猜你喜欢--------------------------------------- */
.cn {
text-align: center;
margin-bottom: 0.625rem;
}
.goods-like {
display: flex;
flex-flow: wrap;
}
.goods-like .like-top {
flex: 1 1 calc(50% - 1.25rem);
font-size: 0.75rem;
display: flex;
flex-flow: column;
padding: 0.625rem;
background-color: white;
border-radius: 0.625rem;
margin: 0.625rem;
}
.goods-like .like-top img {
width: 100%;
height: 100%;
}
.goods-like .like-top p {
min-height: 32px;
margin-top: 0.3125rem;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.like-button {
display: flex;
margin-top: 16px;
justify-content: space-between;
}
.like-button > span:first-of-type {
color: red;
}
.like-button > span:last-of-type {
color: #aaa;
background-color: #f6f6f6;
border-radius: 1rem;
padding: 0.125rem 0.625rem;
}
<!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">
<title>Document</title>
<link rel="stylesheet" href="static/css/index.css">
<link rel="stylesheet" href="static/icon-font/iconfont.css">
</head>
<body>
<header class="header">
<div class="menu iconfont icon-menu"></div>
<div class="search">
<div class="jd">JD</div>
<div class="zoom iconfont icon-search"></div>
<input type="text" class="words" value="扫描仪">
</div>
<a href="#" class="login">登录</a>
</header>
<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="">充值缴费</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="ms">
<div class="ms-top">
<div class="ms-left">
<div class="title">京东秒杀</div>
<div class="ms-sj">01:02:03</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">3456</div>
<div class="iconfont icon-rmb">4567</div>
</li>
<li class="item">
<a href=""><img src="static/images/ms/ms-3.jpg" alt=""></a>
<div class="iconfont icon-rmb">789</div>
<div class="iconfont icon-rmb">999</div>
</li>
<li class="item">
<a href=""><img src="static/images/ms/ms-4.jpg" alt=""></a>
<div class="iconfont icon-rmb">3213</div>
<div class="iconfont icon-rmb">4532</div>
</li>
</ul>
</div>
<!-- -----------------猜你喜欢 ---------------------------->
<h2 class="cn">猜你喜欢</h2>
<div class="goods-like">
<div class="like-top">
<img src="static/images/sp/sp-1.webp" alt="" />
<p> 翻斗鞋柜超薄门厅柜17cm大容量家具组装客厅简约现代 柚</p>
<div class="like-button">
<span>399</span>
<span>看相似</span>
</div>
</div>
<div class="like-top">
<img src="static/images/sp/sp-2.webp" alt="" />
<p> 翻斗鞋柜超薄门厅柜17cm大容量家具组装客厅简约现代 柚木 </p>
<div class="like-button">
<span>399</span>
<span>看相似</span>
</div>
</div>
<div class="like-top">
<img src="static/images/sp/sp-3.webp" alt="" />
<p> 翻斗鞋柜超薄门厅柜17cm大容量家具组装客厅简约现代 柚木色</p>
<div class="like-button">
<span>399</span>
<span>看相似</span>
</div>
</div>
<div class="like-top">
<img src="static/images/sp/sp-4.webp" alt="" />
<p> 翻斗鞋柜超薄门厅柜17cm大容量家具组装客厅简约现代木色 </p>
<div class="like-button">
<span>399</span>
<span>看相似</span>
</div>
</div>
</div>
</div>
<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-kehuguanli"></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>