Parcourir la source

携程手机端Flex布局

Cathy il y a 4 ans
Parent
commit
69e60e3eed

+ 260 - 0
ctrip-mobile/css/index.css

@@ -0,0 +1,260 @@
+body {
+  overflow-x: hidden;
+  -webkit-tap-highlight-color: transparent;
+  -webkit-text-size-adjust: none;
+  -moz-user-select: none;
+  max-width: 540px;
+  margin: 0 auto;
+  background: #fafafc;
+  height: 2000px;
+}
+ul {
+  margin: 0;
+  padding: 0;
+  list-style: none;
+}
+a {
+  text-decoration: none;
+  color: #222;
+}
+/* 搜索模块 */
+.search-index {
+  display: flex;
+  /* 固定定位跟父级没有关系,以屏幕为准 */
+  position: fixed;
+  /* 固定的盒子要有宽度 */
+  width: 100%;
+  height: 44px;
+  min-width: 320px;
+  max-width: 540px;
+  top: 0;
+  left: 50%;
+  -webkit-transform: translate(-50%);
+  transform: translateX(-50%);
+  border-top: 1px solid #ccc;
+  background-color: #f6f6f6;
+  border-bottom: 1px solid #ccc;
+}
+.search {
+  position: relative;
+  flex: 1;
+  box-sizing: border-box;
+  height: 26px;
+  line-height: 24px;
+  border: 1px solid #ccc;
+  border-radius: 5px;
+  margin: 8px 10px;
+  font-size: 12px;
+  color: #666;
+  padding-left: 25px;
+  box-shadow: 0 2px 4px rgb(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;
+  font-size: 12px;
+  text-align: center;
+  color: #2eaae0;
+}
+.user::before {
+  content:"";
+  display: block;
+  width: 23px;
+  height: 23px;
+  background: url(../images/sprite.png) no-repeat -59px -194px;
+  background-size: 104px auto;
+  margin: 5px auto 0;
+}
+/* 焦点图 */
+.focus {
+  padding-top: 44px;
+}
+.focus img {
+  width: 100%;
+}
+/* 局部导航栏 */
+.local-nav {
+  display: flex;
+  height: 64px;
+  margin: 2px 4px;
+  border-radius: 8px;
+}
+.local-nav li{
+  flex: 1;
+}
+.local-nav a{
+  display: flex;
+  flex-direction: column;
+  /* 侧轴居中对齐 */
+  font-size: 12px;
+  align-items: center;
+}
+.local-nav li [class^='local-nav-icon'] {
+  width: 32px;
+  height: 32px;
+  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 {
+  border-radius: 8px;
+  margin: 3px 4px 0;
+}
+.nav-common {
+  display: flex;
+  height: 88px;
+  border-radius: 8px;
+  background-color:rgb(155, 48, 66);
+}
+.nav-common:nth-child(1) {
+  background: -webkit-linear-gradient(left, #ef5a55, #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);
+}
+.nav-common:nth-child(2) {
+  margin: 4px 0;
+}
+.nav-items {
+  flex: 1;
+  display: flex;
+  flex-direction: column;
+}
+.nav-items a {
+  line-height: 44px;
+  align-items: center;
+  text-align: center;
+  flex: 1;
+  color: #fff;
+  font-size: 14px;
+  /* 文字阴影 */
+  text-shadow: 1px 1px rgb(0,0,0,.2);
+}
+.nav-items a:first-child {
+  border-bottom: 1px solid #fff;
+}
+.nav-items:first-child a {
+  border-bottom: none;
+  background: url(../images/hotel.png) no-repeat bottom center;
+  background-size: 121px auto;
+}
+.nav-items:nth-child(-n+2){
+  border-right: 1px solid #fff;
+}
+/* 侧导航栏 */
+.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 a [class^=subnav-entry-icon] {
+  width: 28px;
+  height: 28px;
+  background-color: pink;
+  margin-top: 4px;
+  background: url(../images/subnav-bg.png) no-repeat;
+  background-size: 28px auto;
+}
+.subnav-entry a .subnav-entry-icon2 {
+  background-position: 0 -64px;
+}
+.subnav-entry a .subnav-entry-icon3 {
+  background-position: 0 -100px;
+}
+/* 销售模块 */
+.sales-box {
+  border-top: 1px solid #ccc;
+  margin-top: 4px;
+  background-color:#fff;
+}
+.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;
+  content: "";
+  width: 79px;
+  height: 15px;
+  background: url(../images/hot.png) no-repeat 0 -20px;
+  background-size: 79px auto;
+  top: 10px;
+  left: 20px;
+}
+.more {
+  position: absolute;
+  right: 5px;
+  top: 8px;
+  background: -webkit-linear-gradient(left, #ff505c, #ff6bc6);
+  border-radius: 15px;
+  padding: 3px 20px 3px 10px;
+  color: #fff;
+}
+.more::after {
+  content:"";
+  position: absolute;
+  top: 7px;
+  right: 7px;
+  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%;
+}

+ 461 - 0
ctrip-mobile/css/normalize.css

@@ -0,0 +1,461 @@
+/*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */
+
+/**
+ * 1. Change the default font family in all browsers (opinionated).
+ * 2. Correct the line height in all browsers.
+ * 3. Prevent adjustments of font size after orientation changes in
+ *    IE on Windows Phone and in iOS.
+ */
+
+/* Document
+   ========================================================================== */
+
+html {
+  font-family: sans-serif; /* 1 */
+  line-height: 1.15; /* 2 */
+  -ms-text-size-adjust: 100%; /* 3 */
+  -webkit-text-size-adjust: 100%; /* 3 */
+}
+
+/* Sections
+   ========================================================================== */
+
+/**
+ * Remove the margin in all browsers (opinionated).
+ */
+
+body {
+  margin: 0;
+}
+
+/**
+ * Add the correct display in IE 9-.
+ */
+
+article,
+aside,
+footer,
+header,
+nav,
+section {
+  display: block;
+}
+
+/**
+ * Correct the font size and margin on `h1` elements within `section` and
+ * `article` contexts in Chrome, Firefox, and Safari.
+ */
+
+h1 {
+  font-size: 2em;
+  margin: 0.67em 0;
+}
+
+/* Grouping content
+   ========================================================================== */
+
+/**
+ * Add the correct display in IE 9-.
+ * 1. Add the correct display in IE.
+ */
+
+figcaption,
+figure,
+main { /* 1 */
+  display: block;
+}
+
+/**
+ * Add the correct margin in IE 8.
+ */
+
+figure {
+  margin: 1em 40px;
+}
+
+/**
+ * 1. Add the correct box sizing in Firefox.
+ * 2. Show the overflow in Edge and IE.
+ */
+
+hr {
+  box-sizing: content-box; /* 1 */
+  height: 0; /* 1 */
+  overflow: visible; /* 2 */
+}
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+
+pre {
+  font-family: monospace, monospace; /* 1 */
+  font-size: 1em; /* 2 */
+}
+
+/* Text-level semantics
+   ========================================================================== */
+
+/**
+ * 1. Remove the gray background on active links in IE 10.
+ * 2. Remove gaps in links underline in iOS 8+ and Safari 8+.
+ */
+
+a {
+  background-color: transparent; /* 1 */
+  -webkit-text-decoration-skip: objects; /* 2 */
+}
+
+/**
+ * Remove the outline on focused links when they are also active or hovered
+ * in all browsers (opinionated).
+ */
+
+a:active,
+a:hover {
+  outline-width: 0;
+}
+
+/**
+ * 1. Remove the bottom border in Firefox 39-.
+ * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
+ */
+
+abbr[title] {
+  border-bottom: none; /* 1 */
+  text-decoration: underline; /* 2 */
+  text-decoration: underline dotted; /* 2 */
+}
+
+/**
+ * Prevent the duplicate application of `bolder` by the next rule in Safari 6.
+ */
+
+b,
+strong {
+  font-weight: inherit;
+}
+
+/**
+ * Add the correct font weight in Chrome, Edge, and Safari.
+ */
+
+b,
+strong {
+  font-weight: bolder;
+}
+
+/**
+ * 1. Correct the inheritance and scaling of font size in all browsers.
+ * 2. Correct the odd `em` font sizing in all browsers.
+ */
+
+code,
+kbd,
+samp {
+  font-family: monospace, monospace; /* 1 */
+  font-size: 1em; /* 2 */
+}
+
+/**
+ * Add the correct font style in Android 4.3-.
+ */
+
+dfn {
+  font-style: italic;
+}
+
+/**
+ * Add the correct background and color in IE 9-.
+ */
+
+mark {
+  background-color: #ff0;
+  color: #000;
+}
+
+/**
+ * Add the correct font size in all browsers.
+ */
+
+small {
+  font-size: 80%;
+}
+
+/**
+ * Prevent `sub` and `sup` elements from affecting the line height in
+ * all browsers.
+ */
+
+sub,
+sup {
+  font-size: 75%;
+  line-height: 0;
+  position: relative;
+  vertical-align: baseline;
+}
+
+sub {
+  bottom: -0.25em;
+}
+
+sup {
+  top: -0.5em;
+}
+
+/* Embedded content
+   ========================================================================== */
+
+/**
+ * Add the correct display in IE 9-.
+ */
+
+audio,
+video {
+  display: inline-block;
+}
+
+/**
+ * Add the correct display in iOS 4-7.
+ */
+
+audio:not([controls]) {
+  display: none;
+  height: 0;
+}
+
+/**
+ * Remove the border on images inside links in IE 10-.
+ */
+
+img {
+  border-style: none;
+}
+
+/**
+ * Hide the overflow in IE.
+ */
+
+svg:not(:root) {
+  overflow: hidden;
+}
+
+/* Forms
+   ========================================================================== */
+
+/**
+ * 1. Change the font styles in all browsers (opinionated).
+ * 2. Remove the margin in Firefox and Safari.
+ */
+
+button,
+input,
+optgroup,
+select,
+textarea {
+  font-family: sans-serif; /* 1 */
+  font-size: 100%; /* 1 */
+  line-height: 1.15; /* 1 */
+  margin: 0; /* 2 */
+}
+
+/**
+ * Show the overflow in IE.
+ * 1. Show the overflow in Edge.
+ */
+
+button,
+input { /* 1 */
+  overflow: visible;
+}
+
+/**
+ * Remove the inheritance of text transform in Edge, Firefox, and IE.
+ * 1. Remove the inheritance of text transform in Firefox.
+ */
+
+button,
+select { /* 1 */
+  text-transform: none;
+}
+
+/**
+ * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`
+ *    controls in Android 4.
+ * 2. Correct the inability to style clickable types in iOS and Safari.
+ */
+
+button,
+html [type="button"], /* 1 */
+[type="reset"],
+[type="submit"] {
+  -webkit-appearance: button; /* 2 */
+}
+
+/**
+ * Remove the inner border and padding in Firefox.
+ */
+
+button::-moz-focus-inner,
+[type="button"]::-moz-focus-inner,
+[type="reset"]::-moz-focus-inner,
+[type="submit"]::-moz-focus-inner {
+  border-style: none;
+  padding: 0;
+}
+
+/**
+ * Restore the focus styles unset by the previous rule.
+ */
+
+button:-moz-focusring,
+[type="button"]:-moz-focusring,
+[type="reset"]:-moz-focusring,
+[type="submit"]:-moz-focusring {
+  outline: 1px dotted ButtonText;
+}
+
+/**
+ * Change the border, margin, and padding in all browsers (opinionated).
+ */
+
+fieldset {
+  border: 1px solid #c0c0c0;
+  margin: 0 2px;
+  padding: 0.35em 0.625em 0.75em;
+}
+
+/**
+ * 1. Correct the text wrapping in Edge and IE.
+ * 2. Correct the color inheritance from `fieldset` elements in IE.
+ * 3. Remove the padding so developers are not caught out when they zero out
+ *    `fieldset` elements in all browsers.
+ */
+
+legend {
+  box-sizing: border-box; /* 1 */
+  color: inherit; /* 2 */
+  display: table; /* 1 */
+  max-width: 100%; /* 1 */
+  padding: 0; /* 3 */
+  white-space: normal; /* 1 */
+}
+
+/**
+ * 1. Add the correct display in IE 9-.
+ * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.
+ */
+
+progress {
+  display: inline-block; /* 1 */
+  vertical-align: baseline; /* 2 */
+}
+
+/**
+ * Remove the default vertical scrollbar in IE.
+ */
+
+textarea {
+  overflow: auto;
+}
+
+/**
+ * 1. Add the correct box sizing in IE 10-.
+ * 2. Remove the padding in IE 10-.
+ */
+
+[type="checkbox"],
+[type="radio"] {
+  box-sizing: border-box; /* 1 */
+  padding: 0; /* 2 */
+}
+
+/**
+ * Correct the cursor style of increment and decrement buttons in Chrome.
+ */
+
+[type="number"]::-webkit-inner-spin-button,
+[type="number"]::-webkit-outer-spin-button {
+  height: auto;
+}
+
+/**
+ * 1. Correct the odd appearance in Chrome and Safari.
+ * 2. Correct the outline style in Safari.
+ */
+
+[type="search"] {
+  -webkit-appearance: textfield; /* 1 */
+  outline-offset: -2px; /* 2 */
+}
+
+/**
+ * Remove the inner padding and cancel buttons in Chrome and Safari on macOS.
+ */
+
+[type="search"]::-webkit-search-cancel-button,
+[type="search"]::-webkit-search-decoration {
+  -webkit-appearance: none;
+}
+
+/**
+ * 1. Correct the inability to style clickable types in iOS and Safari.
+ * 2. Change font properties to `inherit` in Safari.
+ */
+
+::-webkit-file-upload-button {
+  -webkit-appearance: button; /* 1 */
+  font: inherit; /* 2 */
+}
+
+/* Interactive
+   ========================================================================== */
+
+/*
+ * Add the correct display in IE 9-.
+ * 1. Add the correct display in Edge, IE, and Firefox.
+ */
+
+details, /* 1 */
+menu {
+  display: block;
+}
+
+/*
+ * Add the correct display in all browsers.
+ */
+
+summary {
+  display: list-item;
+}
+
+/* Scripting
+   ========================================================================== */
+
+/**
+ * Add the correct display in IE 9-.
+ */
+
+canvas {
+  display: inline-block;
+}
+
+/**
+ * Add the correct display in IE.
+ */
+
+template {
+  display: none;
+}
+
+/* Hidden
+   ========================================================================== */
+
+/**
+ * Add the correct display in IE 10-.
+ */
+
+[hidden] {
+  display: none;
+}

BIN
ctrip-mobile/images/hot.png


BIN
ctrip-mobile/images/hotel.png


BIN
ctrip-mobile/images/localnav_bg.png


BIN
ctrip-mobile/images/sprite.png


BIN
ctrip-mobile/images/subnav-bg.png


+ 219 - 0
ctrip-mobile/index.html

@@ -0,0 +1,219 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+  <meta charset="UTF-8">
+  <!-- 视口标签 -->
+  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, maximum-scal=1.0, minimum-scale=1.0">
+  <title>携程在手,说走就走</title>
+  <!-- 引入CSS初始化 -->
+  <link rel="stylesheet" href="css/normalize.css">
+  <!-- 引入首页的CSS -->
+  <link rel="stylesheet" href="css/index.css">
+</head>
+<body>
+  <!-- 顶部搜索 -->
+  <div class="search-index">
+    <div class="search">
+      搜索目的地/酒店/航班号/景点
+    </div>
+    <a href="#" class="user">
+      我 的
+    </a>
+  </div>
+  <!-- 焦点图 -->
+  <div class="focus">
+    <img src="upload/focus.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 ">
+      <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>
+  <!-- 侧导航栏入口 -->
+  <ul class="subnav-entry">
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon2">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon3">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </span>
+        <span>电话费</span>
+      </a>
+    </li>
+    <li>
+      <a href="#">
+        <span class="subnav-entry-icon">
+          
+        </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/pic1.jpg" alt="">
+        </a>
+        <a href="#">
+          <img src="upload/pic2.jpg" alt="">
+        </a>
+      </div>
+      <div class="row">
+        <a href="#">
+          <img src="upload/pic3.jpg" alt="">
+        </a>
+        <a href="#">
+          <img src="upload/pic4.jpg" alt="">
+        </a>
+      </div>
+      <div class="row">
+        <a href="#">
+          <img src="upload/pic5.jpg" alt="">
+        </a>
+        <a href="#">
+          <img src="upload/pic6.jpg" alt="">
+        </a>
+      </div>
+    </div>
+  </div>
+</body>
+</html>

BIN
ctrip-mobile/upload/focus.jpg


BIN
ctrip-mobile/upload/pic1.jpg


BIN
ctrip-mobile/upload/pic2.jpg


BIN
ctrip-mobile/upload/pic3.jpg


BIN
ctrip-mobile/upload/pic4.jpg


BIN
ctrip-mobile/upload/pic5.jpg


BIN
ctrip-mobile/upload/pic6.jpg