flex为主其他为辅废话不多说上代码:
其中的图片都是去官网直接下载的
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<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 class="user">我 的</a>
</div>
<!-- 焦点图模块 -->
<div class="focus">
<img src="upload/zg0p1d000001eno3o7583.jpg" alt="">
</div>
<!-- 局部导航栏 -->
<ul class="local-nav">
<li>
<a href="#" title=" ">
<span class="local-nav-icon-icon1"></span>
<span>攻略·景点</span>
</a>
</li>
<li>
<a href="#" title=" ">
<span class="local-nav-icon-icon2"></span>
<span>门票·玩乐</span>
</a>
</li>
<li>
<a href="#" title=" ">
<span class="local-nav-icon-icon3"></span>
<span>美食林</span>
</a>
</li>
<li>
<a href="#" title=" ">
<span class="local-nav-icon-icon4"></span>
<span>周边游</span>
</a>
</li>
<li>
<a href="#" title=" ">
<span class="local-nav-icon-icon5"></span>
<span>一日游</span>
</a>
</li>
</ul>
<!-- 主导航栏 -->
<nav>
<div class="nav-common row1">
<div class="nav-items">
<a href="">酒店</a>
</div>
<div class="nav-items">
<a href="">民宿·客栈</a>
</div>
<div class="nav-items">
<a href="">机票/火车票+酒店</a>
</div>
</div>
<div class="nav-common row2">
<div class="nav-items">
<a href="">机票</a>
</div>
<div class="nav-items">
<a href="">火车票</a>
</div>
<div class="nav-items">
<a href="">汽车·船票</a>
</div>
<div class="nav-items">
<a href="">专车·出租</a>
</div>
</div>
<div class="nav-common row3">
<div class="nav-items">
<a href="">旅游</a>
</div>
<div class="nav-items">
<a href="">高铁游</a>
</div>
<div class="nav-items">
<a href="">邮轮游</a>
</div>
<div class="nav-items">
<a href="">定制游</a>
</div>
</div>
</nav>
<!-- /* 侧导航栏 */ -->
<ul class="subnav-entry">
<li>
<a href="">
<span class="subnav-entry-icon-icon1"></span>
<span>自由行</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon2"></span>
<span>wifi电话卡</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon3"></span>
<span>保险·签证</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon4"></span>
<span>换钞·购物</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon5"></span>
<span>当地向导</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon6"></span>
<span>特价机票</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon7"></span>
<span>礼品卡</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon8"></span>
<span>申卡·借钱</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon9"></span>
<span>旅拍</span>
</a>
</li>
<li>
<a href="">
<span class="subnav-entry-icon-icon10"></span>
<span>更多</span>
</a>
</li>
</ul>
<!-- 销售模块 -->
<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/1.jpg" alt="">
</a>
<a href="#">
<img src="upload/2.jpg" alt="">
</a>
</div>
<div class="row">
<a href="#">
<img src="upload/3.jpg" alt="">
</a>
<a href="#">
<img src="upload/4.jpg" alt="">
</a>
</div>
<div class="row">
<a href="#">
<img src="upload/5.jpg" alt="">
</a>
<a href="#">
<img src="upload/6.jpg" alt="">
</a>
</div>
</div>
</div>
<!-- footer -->
<footer>
<div class="tel">
<span class="tel-icon"></span>
<span>电话预约</span>
</div>
<div class="download">
<span class="download-icon"></span>
<span>下载客户端</span>
</div>
<div class="about">
<span class="about-icon"></span>
<span>我的</span>
</div>
</footer>
<!-- 最最底部 -->
<div class="lastbottom">
<a href="#">
<p align=center> 网站地图| 🌏 Language ∨   | 电脑板</p>
<p align=center>©2020携程旅行|沪ICP备08023580号</p>
</a>
</div>
</body>
</html>
css:
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-heightlight-color:transparent ;
height: 1000px;
}
ul{
margin: 0px;
padding: 0px;
list-style: none;
}
a{
text-decoration:none;
color: #222;
}
div{
box-sizing: border-box;
}
.search-index{
display: flex;
/* 固定定位与屏幕没有关系,以屏幕为准 */
position: fixed;
top: 0;
left: 50%;
transform: translate(-50%);
width: 100%;
height: 44px;
min-width: 320px;
max-width: 540px;
/* background-color: pink; */
}
.search{
background-color: #fff;
position: relative;
height: 26px;
line-height: 24px;
border: 1px solid #ccc;
flex: 1;
font-size: 12px;
color: #666;
padding-left: 25px;
margin: 7px 10px;
border-radius: 5px;
box-shadow: 0px 2px 4px rgba(0,0,0,.2);
}
.search::before{
content: "";
position: absolute;
top: 5px;
left: 5px;
width: 15px;
height: 15px;
background: url(../images/sprite.png)no-repeat -59px -279px;
background-size: 104px auto;
}
.user{
width: 44px;
height: 44px;
/* background-color: purple; */
font-size: 12px;
text-align: center;
color: #fff;
}
.user::before{
content: "";
display: block;
width: 23px;
height: 23px;
background: url(../images/home-common-sprite2x@v7.15.png) no-repeat 1px -36px;
background-size: 21px auto;
margin: 4px auto -2px;
}
.focus{
position: relative;
width: 100%;
overflow: hidden;
z-index: -1;
}
.focus img{
width: 100%;
height: 50%;
margin-top: -50px;
vertical-align: top;
border-radius: 0px 0px 20px 20px;
}
/* 局部导航栏 */
.local-nav{
height: 64px;
background-color: #fff;
margin:-60px 12px 10px;
padding: 8px;
border-radius: 8px;
display: flex;
}
.local-nav li{
flex: 1px;
}
.local-nav a{
display: flex;
flex-direction: column;
/* 侧轴居中对齐 */
align-items: center;
font-size: 12px;
}
.local-nav li [class^="local-nav-icon"] {
width: 32px;
height: 32px;
background-color: pink;
margin-top: 8px;
background:url(../images/localnav.bg.png) no-repeat 0 0;
background-size: 32px auto;
}
.local-nav li .local-nav-icon-icon2{
background-position: 0 -32px;
}
.local-nav li .local-nav-icon-icon3{
background-position: 0 -64px;
}
.local-nav li .local-nav-icon-icon4{
background-position: 0 -96px;
}
.local-nav li .local-nav-icon-icon5{
background-position: 0 -128px;
}
/* nav */
.nav-wrap {
border-radius: 8px;
margin: 0 12px;
overflow: hidden;
}
.nav-common {
display: flex;
height: 88px;
background-color: pink;
justify-content: center;
align-items: center;
}
.nav-items a {
display: block;
color: #fff;
font-size: 14px;
height: 88px;
line-height: 88px;
}
/* 从第二个元素开始 */
.nav-items:nth-child(n+1) a {
text-align: center;
}
.nav-items:first-child a {
margin-left: 10px;
text-align: left;
}
.row1 .nav-items:nth-child(1) {
flex: 1.5;
background: linear-gradient(to right, #fa5a56, #fa7252);
}
.row1 .nav-items:nth-child(1) a {
background: url(../images/grid-nav-items-hotel@v7.15.png) no-repeat bottom right;
background-size: 108px auto;
}
.row1 .nav-items:nth-child(2) {
flex: 1;
background: linear-gradient(to right, #fa7252, #fb8550);
}
.row1 .nav-items:nth-child(2) a {
background: url(../images/grid-nav-items-minsu@v7.15.png) no-repeat bottom left;
background-size: 53px auto;
}
/* 前两个元素添加右边框 */
.row1 .nav-items:nth-child(-n+2) {
border-right: 1px solid #fff;
}
.row1 .nav-items:nth-child(3) {
flex: 2;
position: relative;
/* 第一行的三个元素渐变色 覆盖掉上面的那个渐变色 */
background: linear-gradient(to right, #ffbc49, #ffd252);
}
.row1 .nav-items:nth-child(3) a {
background: url(../images/grid-nav-items-jhj@v7.15.png) no-repeat bottom right;
background-size: 87px auto;
}
.row1 .nav-items .specious {
position: absolute;
top: 20px;
right: 48px;
background-color: red;
border-radius: 20px 20px 20px 0;
color: #fff;
padding: 2px 5px;
font-size: 10px;
}
.row2 {
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
background: linear-gradient(to right, #4b8fed, #53bced);
}
/* 前三个元素添加边框 */
.row2 .nav-items:nth-child(-n+3),
.row3 .nav-items:nth-child(-n+3) {
border-right: 1px solid #fff;
}
.row2 .nav-items:first-child {
flex: 1.5;
background: url(../images/grid-nav-items-flight@v7.15.png) no-repeat bottom right;
background-size: 120px auto;
}
.row2 .nav-items,
.row3 .nav-items {
flex: 1;
}
.row2 .nav-items:nth-child(2) {
background: url(../images/grid-nav-items-train.png) no-repeat bottom left;
background-size: 56px auto;
}
.row3 {
background: linear-gradient(to right, #34c2a9, #6cd558);
}
.row3 .nav-items:first-child {
flex: 1.5;
background: url(../images/grid-nav-items-travel@v7.15.png) no-repeat bottom right;
background-size: 140px auto;
}
.row3 .nav-items:nth-child(2) {
background: url(../images/grid-nav-items-dingzhi@v7.15.png) no-repeat bottom left;
background-size: 92px auto;
}
/* subnav-entry */
.subnav-entry{
display: flex;
flex-wrap: wrap;
border-radius: 8px ;
background-color: #fff;
margin: 0 4px;
padding: 5px 0;
}
.subnav-entry li{
/* 里面的子盒子可以用%,相对于父元素来说 */
flex: 20%;
}
.subnav-entry a{
display: flex;
flex-direction: column;
align-items: center;
}
.subnav-entry [class^='subnav-entry-icon'] {
width: 28px;
height: 28px;
background-color: pink;
background: url(../images/un_ico_subnav2x@v7.152.png) no-repeat 0 0;
background-size: 28px auto;
}
.subnav-entry .subnav-entry-icon-icon2 {
background-position: 0 -28px;
}
.subnav-entry .subnav-entry-icon-icon3 {
background-position: 0 -56px;
}
.subnav-entry .subnav-entry-icon-icon4 {
background-position: 0 -84px;
}
.subnav-entry .subnav-entry-icon-icon5 {
background-position: 0 -112px;
}
.subnav-entry .subnav-entry-icon-icon6{
background-position: 0 -140px;
}
.subnav-entry .subnav-entry-icon-icon7 {
background-position: 0 -168px;
}
.subnav-entry .subnav-entry-icon-icon8 {
background-position: 0 -196px;
}
.subnav-entry .subnav-entry-icon-icon9 {
background-position: 0 -224px;
}
.subnav-entry .subnav-entry-icon-icon10 {
background-position: 0 -252px;
}
.sales-box{
border: top 1px solid #ccc ;
background-color: #fff;
margin: 4px;
}
.sales-hd{
position: relative;
height: 44px;
border-bottom: 1px solid #000;
}
.sales-hd h2{
position: relative;
text-indent: -999px;
overflow: hidden;
}
.sales-hd h2::after{
position: absolute;
top: 8px;
left: 20px;
content:"";
width: 79px;
height: 15px;
background:url(../images/un_home_text.png)no-repeat 0 -20px;
background-size: 79px auto;
}
.more{
position: absolute;
right: 5px;
top: 8px;
background: -webkit-linear-gradient(left,#ff506c,#ff6Bc6);
border-radius: 15px;
padding: 3px 20px 3px 10px;
}
.more::after{
content: "";
position: absolute;
top: 7px;
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 #eee;
}
.row a:nth-child(1){
border-right: 1px solid #ccc;
}
.row a img{
width: 100%;
}
.bottom nav {
height: 50px;
border-bottom: 1px solid #ccc;
}
.bottom-nav-items {
display: flex;
justify-content: space-between;
}
.bottom-nav-items li {
flex: 1;
}
.bottom-nav-items li a {
display: flex;
flex-direction: column;
align-items: center;
font-size: 10px;
}
/* footer */
footer {
display: flex;
border-top: 1px solid #ccc;
margin: 8px 0;
background-color: #fff;
padding-bottom: 10px;
}
footer div {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
footer div span:first-child {
width: 20px;
height: 20px;
background-color: pink;
margin: 15px 0 5px 0;
background: url(../images/sprite.png) no-repeat;
background-size: 104px auto;
}
footer .tel .tel-icon {
background-position: -59px -154px;
}
footer .download .download-icon {
background-position: -59px -174px;
}
footer .about .about-icon {
background-position: -59px -309px;
}
.lastbottom {
height: 30px;
border-bottom: 1px solid #ccc;
}
.lastbottom a {
font-size: 10px;
color: gray;
}
还有一个normalize.css文件自己可以去网上搜一下,用到的地方也不少