移动端flex布局——仿携程网

html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scalable=1.0, minimum-scale=1.0"
    />
    <link rel="stylesheet" href="font/iconfont.css" />
    <link rel="stylesheet" href="css/normalize.css" />
    <link rel="stylesheet" href="css/index.css" />
    <title>携程网</title>
  </head>
  <body>
    <header>
      <div class="search">
        <div></div>
        <input type="text" />
      </div>
      <div class="user">
        <div class="mine"></div>
        <div>我 的</div>
      </div>
    </header>
    <div class="main"></div>
    <nav class="iconfont">
      <a href="#">
        <span></span>
        <span>攻略·景点</span>
      </a>
      <a href="#">
        <span></span>
        <span>攻略·景点</span>
      </a>
      <a href="#">
        <span></span>
        <span>攻略·景点</span>
      </a>
      <a href="#">
        <span></span>
        <span>攻略·景点</span>
      </a>
      <a href="#">
        <span></span>
        <span>攻略·景点</span>
      </a>
    </nav>
    <div class="menu">
      <a href="#" class="hotel">
        <span>酒店</span>
        <span>民宿·客栈</span>
        <span>特价·爆款</span>
      </a>
      <a href="#" class="ticket">
        <span>机票</span>
        <span>火车票</span>
        <span>高铁票</span>
        <span>船票</span>
      </a>
      <a href="#" class="travel">
        <span>旅游</span>
        <span>高铁游</span>
        <span>邮轮游</span>
        <span>定制游</span>
      </a>
    </div>
    <div class="subnav iconfont">
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
      <a href="#">
        <span></span>
        <span>自由行</span>
      </a>
    </div>
    <footer>
      <div class="tool iconfont">
        <a href="#">
          <span></span>
          <span>电话预定</span>
        </a>
        <a href="#">
          <span></span>
          <span>电话预定</span>
        </a>
        <a href="#">
          <span></span>
          <span>电话预定</span>
        </a>
      </div>
      <div class="tool_ver iconfont">
        <a href="#">网站地图</a>
        <a href="#">language </a>
        <a href="#">电脑版</a>
      </div>
      <p>©携程旅行|沪ICP备XXXXXXXXX号</p>
    </footer>
  </body>
</html>

CSS

body {
  min-width: 320px;
  max-width: 540px;
  height: 665px;
  font: 14px/1.5 Tahoma, 'Lucida Grande', Verdana, 'Microsoft Yahei';
  margin: 0 auto;
  color: #000;
  background-color: #fafafc;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
a {
  text-decoration: none;
  color: #fff;
}
header {
  position: fixed;
  display: flex;
  align-items: center;
  height: 44px;
  width: 100%;
  min-width: 320px;
  max-width: 540px;
}
header .search {
  display: flex;
  flex: 1;
  height: 28px;
  margin-left: 10px;
  background-color: #fff;
  border-radius: 14px;
  overflow: hidden;
}
header .search div {
  width: 35px;
  height: 100%;
  background-image: url(../images/search.png);
  background-repeat: no-repeat;
  background-position: 10px 6px;
  background-size: 22px auto;
}
header .search input {
  flex: 1;
  border: none;
  outline: none;
}
header .user {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 51px;
  height: 100%;
  color: #fff;
}
header .user .mine {
  width: 22px;
  height: 22px;
  background-image: url(../images/search.png);
  background-repeat: no-repeat;
  background-position: 0 -34px;
  background-size: 22px auto;
}
.main {
  width: 100%;
  height: 247px;
  background-color: #fff;
  background-image: url(../upload/bgpic.jpg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}
nav {
  display: flex;
  justify-self: center;
  align-items: center;
  border-radius: 8px;
  margin: -52px 12px 10px 12px;
  height: 64px;
  justify-content: space-around;
  background-color: #fff;
}
nav a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 20%;
  height: 52px;
  /* body行距1.5,不改行距盒子会变大 */
  line-height: 1;
  color: #000;
  text-decoration: none;
}
nav a span:nth-child(1) {
  width: 40px;
  height: 40px;
}
nav a span:nth-child(2) {
  height: 12px;
  font-size: 12px;
}
nav a span:nth-child(1)::before {
  content: '\e7a0';
  font-size: 40px;
  color: skyblue;
}
.menu {
  height: 198px;
  margin: 0 12px;
  border-radius: 8px;
  overflow: hidden;
}
.menu .hotel,
.menu .ticket,
.menu .travel {
  display: flex;
  height: 65px;
  border-bottom: 1px solid #fff;
}
.menu .hotel span,
.menu .ticket span,
.menu .travel span {
  width: 23%;
  height: 65px;
  line-height: 65px;
  text-align: center;
  background-repeat: no-repeat;
  background-size: 50% 50%;
}
.menu .hotel span:nth-child(1),
.menu .travel span:nth-child(1),
.menu .ticket span:nth-child(1) {
  width: 31%;
  box-sizing: border-box;
  height: 65px;
  text-align: left;
  padding-left: 20px;
  border-right: 1px solid #fff;
  background-position: bottom right;
}
.menu .hotel span:nth-child(3) {
  flex: 1;
}
.menu .hotel {
  background-color: #fa6754;
}
.menu .hotel span:nth-child(1) {
  background-image: url(../upload/pic1.png);
}
.menu .hotel span:nth-child(2) {
  background-image: url(../upload/pic2.png);
  background-position: bottom left;
}
.menu .hotel span:nth-child(3) {
  background-image: url(../upload/pic3.png);
  background-position: right bottom;
  background-size: 120% 150%;
  border-left: 1px solid #fff;
}
.menu .ticket {
  background-color: #4d99ed;
}
.menu .ticket span:nth-child(1) {
  background-image: url(../upload/pic21.png);
}
.menu .ticket span:nth-child(2) {
  background-image: url(../upload/pic22.png);
  background-position: bottom left;
  border-right: 1px solid #fff;
}
.menu .travel {
  background-color: #43c795;
}
.menu .travel span:nth-child(1) {
  background-image: url(../upload/31.png);
}
.menu .travel span:nth-child(2) {
  background-image: url(../upload/pic32.png);
  background-position: bottom left;
  border-right: 1px solid #fff;
}
.menu .ticket span:nth-child(3),
.menu .travel span:nth-child(3) {
  border-right: 1px solid #fff;
}
.subnav {
  display: flex;
  justify-content: space-around;
  align-content: center;
  flex-wrap: wrap;
  height: 110px;
  margin: 0 12px;
}
.subnav a {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  line-height: 1;
  font-size: 12px;
  height: 55px;
  width: 20%;
  color: #000;
}
.subnav a span:nth-child(1)::before {
  content: '\e64a';
  font-size: 28px;
  color: #fd884e;
}
footer {
  height: 124px;
}
footer .tool {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 60px;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  margin: 10px 0;
  background-color: #fff;
}
footer .tool a {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  color: #000;
  margin: 6px 0;
  font-size: 12px;
}
footer .tool a span:nth-child(1)::before {
  content: '\e608';
  font-size: 20px;
  color: #ccc;
}
.tool_ver {
  text-align: center;
}
.tool_ver a {
  display: inline-block;
  font-size: 12px;
  color: #666;
  padding: 0 5px;
  border-right: 1.5px solid #ccc;
}
.tool_ver a:nth-child(2)::before {
  content: '\e718';
  font-size: 11px;
  color: #666;
}
.tool_ver a:nth-child(2)::after {
  content: '\e62d';
  font-size: 11px;
  color: #666;
}
.tool_ver a:nth-child(3) {
  border: none;
}
p {
  text-align: center;
  font-size: 12px;
  color: #ccc;
  margin: 5px 0;
}

在这里插入图片描述

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值