3-1 移动端基础知识
3-2 移动端电商首页制作
body {
width: 100%;
min-width: 320px;
max-width: 640px;
margin:0 auto;
font-size: 14px;
font-family:-apple-system, Helvetica, sans-serif;
color:#666;
line-height:1.5;
}
/* 点击高亮我们需要清除清除 设置为transparent 完全透明 */
* {
-webkit-tap-highlight-color: transparent;
}
/* 在移动端浏览器默认的外观在ios上加上这个属性才能给按钮和输入框自定义样式 */
input {
-webkit-appearance: none;
}
/* 禁用长按页面时的弹出菜单 */
a,
img {
-webkit-touch-callout: none;
}
a {
color:#666;
text-decoration:none;
}
ul {
margin:0;
padding:0;
list-style:none;
}
img {
vertical-align:middle;
}
.app {
height: 45px;
}
.app ul li {
float:left;
height: 45px;
line-height: 45px;
background-color: #333333;
text-align:center;
color:#fff;
}
.app ul li:nth-child(1) {
width: 8%;
}
.app ul li:nth-child(1) img {
width: 15px;
}
.app ul li:nth-child(2) {
width: 10%;
}
.app ul li:nth-child(2) img {
width: 30px;
vertical-align: middle;
}
.app ul li:nth-child(3) {
width: 57%;
}
.app ul li:nth-child(4) {
width: 25%;
background-color: #f63515;
}
/* 搜索 */
.search-wrap {
position: fixed;
overflow:hidden;
width: 100%;
height: 44px;
min-width:320px;
max-width: 640px;
}
.search-btn {
position: absolute;
top:0;
left: 0;
width: 40px;
height: 44px;
}
.search-btn::before {
content:"";
display:block;
width: 20px;
height: 18px;
background: url(../images/btn.png) no-repeat;
background-size: 20px 18px;
margin:14px 0 0 15px;
}
.search-login {
position: absolute;
top:0;
right: 0;
width: 40px;
height: 44px;
color:#fff;
line-height:44px;
}
.search {
position: relative;
height: 30px;
background-color: #fff;
margin:0 50px;
border-radius: 15px;
margin-top:7px;
}
.jd-icon {
width: 20px;
height: 15px;
position: absolute;
top:8px;
left:13px;
background: url(../images/jd.png);
background-size: 20px 15px;
}
.jd-icon::after {
content: "";
position: absolute;
right: -8px;
top:0;
display:block;
width: 1px;
height: 15px;
background-color: #ccc;
}
.sou {
position: absolute;
top: 8px;
left: 50px;
width: 18px;
height: 15px;
background: url(../images/jlt.png) no-repeat -81px 0;
background-size: 200px auto;
}
.slider img {
width: 100%;
}
.brand {
overflow:hidden;
border-radius:10px 10px 0 0;
}
/* 品牌日 */
.brand div {
float:left;
width: 33.33%;
}
.brand div img {
width: 100%;
}
nav {
margin-top:5px;
}
nav a {
float:left;
width: 20%;
text-align: center;
}
nav a img {
width: 40px;
margin:10px 0;
}
nav a span {
display:block;
}
/* news模块 */
.news {
margin-top:20px;
}
.news img {
width: 100%;
}
.news a {
float:left;
box-sizing: border-box;
}
.news a:nth-child(1) {
width: 50%;
}
.news a:nth-child(n+2) {
width: 25%;
border-left:1px solid #ccc;
}
index.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,user-scalable=no,maximum-scale=1.0,minimum-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<!-- 顶部 -->
<header class="app">
<ul>
<li><img src="images/x.png" alt=""></li>
<li><img src="images/logo.png" alt=""></li>
<li>打开京东APP,购物更轻松</li>
<li>立即打开</li>
</ul>
</header>
<!-- 搜索 -->
<div class="search-wrap">
<div class="search-btn"></div>
<div class="search">
<div class="jd-icon"></div>
<div class="sou"></div>
</div>
<div class="search-login">登录</div>
</div>
<!-- 主体内容部分 -->
<div class="main-content">
<!-- 滑动图 -->
<div class="slider">
<img src="upload/sp1.png" alt="">
</div>
<!-- 品牌日 -->
<div class="brand">
<div>
<a href="#"><img src="upload/sp2.png" alt=""></a>
</div>
<div>
<a href="#"><img src="upload/sp2.png" alt=""></a>
</div>
<div>
<a href="#"><img src="upload/sp2.png" alt=""></a>
</div>
</div>
<!-- nav部分 -->
<nav>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
<a href="">
<img src="images/bt1.png" alt="">
<span>京东超市</span>
</a>
</nav>
<!-- 新闻模块 -->
<div class="news">
<a href="#"><img src="upload/sp3.png" alt=""></a>
<a href="#"><img src="upload/sp4.png" alt=""></a>
<a href="#"><img src="upload/sp5.png" alt=""></a>
</div>
</div>
</body>
</html>
3-3 Flex伸缩布局基础知识
3-4 移动端携程网首页制作
12-首页布局分析以及搜索模块布局
13-搜索模块user制作
body {
max-width: 540px;
min-width: 320px;
margin:0 auto;
font:normal 14px/1.5 Tahoma,"Lucida Grande",Verdana,"Microsoft Yahei", STXihei,hei;
color:#000;
background: #f2f2f2;
overflow-x:hidden;
-webkit-tap-highlight-color:transparent;
}
li {
list-style:none;
margin:0;
padding:0;
}
a {
text-decoration: none;
color:#222;
}
div {
box-sizing:border-box;
}
/* 搜索模块 */
.search-index {
display:flex;
/* 固定定位跟父级没有关系 它以屏幕为准 */
position:fixed;
top:0;
left:50%;
/* 固定的盒子应该有宽度 */
-webkit-transform:translateX(-50%);
transform:translateX(-50%);
width: 100%;
min-width: 320px;
max-width: 540px;
height: 44px;
background-color: #f4f4f4;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
.search {
position: relative;
height: 26px;
line-height: 24px;
border:1px solid #ccc;
flex:1;
font-size: 12px;
color:#666;
margin:6px 10px;
padding-left:25px;
border-radius:5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
}
.search::before {
content:"";
position: absolute;
top:5px;
left:5px;
width: 14px;
height: 13px;
background: url(../images/sprite.png) no-repeat -57px -263px;
background-size: 104px auto;
}
.user {
width: 44px;
height: 44px;
font-size:12px;
text-align:center;
color:#2eaae0;
}
.user::before {
content:"";
display:block;
width: 22px;
height: 24px;
background: url(../images/sprite.png) no-repeat -57px -182px;
background-size: 104px auto;
margin:5px auto -2px;
}
/* focus */
.focus {
padding-top:40px;
}
.focus img {
width: 100%;
}
/* 局补助导航栏 */
.local-nav {
display:flex;
height: 64px;
background-color: #fff;
margin:3px 4px;
border-radius: 8px;
}
.local-nav li {
flex:1;
}
.local-nav a {
display:flex;
flex-direction:column;
align-items: center;
font-size: 12px;
}
.local-nav-icon {
width: 32px;
height: 32px;
background-color: pink;
margin-top:8px;
background: url(../images/sprite1.png) no-repeat -10px -10px;
}
/* nav */
nav {
overflow:hidden;
border-radius:8px;
margin:0 4px 3px;
}
.nav-common {
display:flex;
height:88px;
}
.nav-common:nth-child(2) {
margin:3px 0;
}
.nav-items {
flex:1;
display:flex;
flex-direction:column;
}
.nav-items a {
flex:1;
text-align:center;
line-height:44px;
color:#fff;
font-size:14px;
text-shadow:1px 1px rgba(0, 0, 0, .2);
}
.nav-items a:nth-child(1) {
border-bottom: 1px solid #fff;
}
.nav-items:nth-child(1) a {
border:0;
background:url(../images/hotel.png) no-repeat 20px 10px;
}
.nav-items:nth-child(-n+2) {
border-right:1px solid #fff;
}
.nav-common:nth-child(1) {
background: -webkit-linear-gradient(left, #fa5a55,#fa994d);
}
.nav-common:nth-child(2) {
background: -webkit-linear-gradient(left, #4b90ed,#53bced);
}
.nav-common:nth-child(3) {
background: -webkit-linear-gradient(left, #34c2a9,#6cd559);
}
/* subnav-entry */
.subnav-entry {
display:flex;
border-radius: 8px;
background-color: #fff;
margin:0 4px;
flex-wrap:wrap;
padding:5px 0;
}
.subnav-entry li {
flex:20%;
}
.subnav-entry a {
display:flex;
flex-direction: column;
align-items:center;
font-size:12px;
}
.subnav-entry-icon {
width: 28px;
height: 28px;
background-color: pink;
margin-top:4px;
background: url(../images/p1.png) no-repeat;
}
/* sales-box */
.sales-box {
border-top: 1px solid #bbb;
background-color: #fff;
margin:4px;
}
.sales-hd {
position: relative;
height: 44px;
border-bottom: 1px solid #ccc;
}
.sales-hd h2 {
position:relative;
text-indent:-999px;
overflow:hidden;
}
.sales-hd h2::after {
position: absolute;
top: 8px;
left: 20px;
content:"";
width: 79px;
height: 20px;
background: url(../images/p2.png) no-repeat;
background-size: 79px auto;
}
.more {
position: absolute;
right:5px;
top:5px;
background: -webkit-linear-gradient(left,#ff506c,#ff6bc6);
border-radius: 15px;
padding: 3px 20px 3px 10px;
color: #fff;
}
.more::after {
content:"";
position: absolute;
top: 9px;
right: 9px;
width: 7px;
height: 7px;
border-top: 2px solid #fff;
border-right: 2px solid #fff;
transform:rotate(45deg);
}
.row {
display:flex;
}
.row a {
flex:1;
border-bottom: 1px solid #ccc;
}
.row a:nth-child(1) {
border-right: 1px solid #ccc;
}
.row a img {
width: 100%;
}
index.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">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/index.css">
<title>携程在手,说走就走</title>
</head>
<body>
<!-- 顶部搜索 -->
<div class="search-index">
<div class="search">搜索:目的地/酒店/景点/航班号</div>
<a href="#" class="user">我 的</a>
</div>
<!-- 焦点图模块 -->
<div class="focus">
<img src="upload/p1.png" alt="">
</div>
<!-- 局部导航栏 -->
<ul class="local-nav">
<li>
<a href="#" title="景点.玩乐">
<span class="local-nav-icon"></span>
<span>景点.玩乐</span>
</a>
</li>
<li>
<a href="#" title="景点.玩乐">
<span class="local-nav-icon"></span>
<span>景点.玩乐</span>
</a>
</li>
<li>
<a href="#" title="景点.玩乐">
<span class="local-nav-icon"></span>
<span>景点.玩乐</span>
</a>
</li>
<li>
<a href="#" title="景点.玩乐">
<span class="local-nav-icon"></span>
<span>景点.玩乐</span>
</a>
</li>
<li>
<a href="#" title="景点.玩乐">
<span class="local-nav-icon"></span>
<span>景点.玩乐</span>
</a>
</li>
</ul>
<!-- 主导航栏 -->
<nav>
<div class="nav-common">
<div class="nav-items">
<a href="#">海外酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
</div>
<div class="nav-common">
<div class="nav-items">
<a href="#">海外酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
</div>
<div class="nav-common">
<div class="nav-items">
<a href="#">海外酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
<div class="nav-items">
<a href="#">海外酒店</a>
<a href="#">特价酒店</a>
</div>
</div>
</nav>
<!-- 侧导航栏 -->
<div class="subnav-entry">
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
<li>
<a href="#">
<div class="subnav-entry-icon"></div>
<span>电话费</span>
</a>
</li>
</div>
<!-- 销售模块 -->
<div class="sales-box">
<div class="sales-hd">
<h2>热门活动</h2>
<a href="#" class="more">获取更多福利</a>
</div>
<div class="sales-bd">
<div class="row">
<a href="#">
<img src="upload/up2.png" alt="">
</a>
<a href="#">
<img src="upload/up2.png" alt="">
</a>
</div>
<div class="row">
<a href="#">
<img src="upload/up2.png" alt="">
</a>
<a href="#">
<img src="upload/up2.png" alt="">
</a>
</div>
<div class="row">
<a href="#">
<img src="upload/up2.png" alt="">
</a>
<a href="#">
<img src="upload/up2.png" alt="">
</a>
</div>
</div>
</div>
</body>
</html>