前端移动Web第二天:Flex伸缩布局-携程首页案例

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;
}
a {
     
    text-decoration: none;
    color: #222;
}
div {
     
    box-sizing: border-box;
}
ul {
     
    list-style: none;
    margin: 0;
    padding: 0;
}

/* 搜索模块: */
.search-index {
     
    display: flex;
    /* 固定定位跟父级没有关系,它以屏幕为准 */
    position: fixed;
    top: 0;
    left: 50%;

    /* 用CSS3里面的内容居中: */
    transform: translate(-50%);
    /* 固定的盒子应该有宽度: */
    width: 100%;
    max-width: 540px;
    min-width: 320px;
    height: 44px;

    background-color: #F6F6F6;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}
.search {
     
    position: relative;

    flex: 1;
    font-size: 12px;
    color: #666;
    height: 26px;
    line-height: 24px;
    border: 1px solid #ccc;
    margin: 7px 10px;
    padding-left: 25px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.search::before {
     
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 15px;
    height: 15px;
    background: url(../images/sprite.png) no-repeat -59px -279px;
    background-size: 104px auto;
    margin: 5px;
}
.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: 4px auto -2px;
}

/* 焦点图模块 */
.focus {
     
    padding-top: 44px;
}
.focus img {
     
    width: 100%;
}

/* 局部小导航栏 */
.local-nav {
     
    display: flex;
    height: 64px;
    background-color: #fff;
    border-radius: 8px;
    margin: 3px 4px;
}
.local-nav li {
     
    flex: 1;
}
.local-nav a {
     
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
}
.local-nav-icon1 {
     
    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-icon2 {
     
    width: 32px;
    height: 32px;
    background-color: pink;
    margin-top: 8px;
    background: url(../images/localnav_bg.png) no-repeat 0 -32px;
    background-size: 32px auto;
}
.local-nav-icon3 {
     
    width: 32px;
    height: 32px;
    background-color: pink;
    margin-top: 8px;
    background: url(../images/localnav_bg.png) no-repeat 0 -64px;
    background-size: 32px auto;
}
.local-nav-icon4 {
     
    width: 32px;
    height: 32px;
    background-color: pink;
    margin-top: 8px;
    background: url(../images/localnav_bg.png) no-repeat 0 -96px;
    background-size: 32px auto;
}
.local-nav-icon5 {
     
    width: 32px;
    height: 32px;
    background-color: pink;
    margin-top: 8px;
    background: url(../images/localnav_bg.png) no-repeat 0 -128px;
    background-size: 32px auto;
}


nav {
     
    overflow: hidden;
    border-radius: 8px;
    margin: 0 4px 3px;
}
.nav-common {
     
    height: 88px;
    background-color: pink;
    display: flex;
}
.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;
}
/* 第一列的a 不需要下划线: */
.nav-items:nth-child(1) a {
     
    border: 0;
    background: url(../images/hotel.png) no-repeat bottom center;
    background-size: 121px auto;
}

/* -n+2就是选择前面两个元素: */
.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 {
     
    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;
}
.subnav-entry-icon1 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat;
    background-size: 28px auto;
}
.subnav-entry-icon2 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 0 -30px;
    background-size: 28px auto;
}
.subnav-entry-icon3 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 0 -65px;
    background-size: 28px auto;
}
.subnav-entry-icon4 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 0 -100px;
    background-size: 28px auto;
}
.subnav-entry-icon5 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 0 -130px;
    background-size: 28px auto;
}
.subnav-entry-icon6 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 5px -162px;
    background-size: 28px auto;
}
.subnav-entry-icon7 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 0 -195px;
    background-size: 28px auto;
}
.subnav-entry-icon8 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 0 -225px;
    background-size: 28px auto;
}
.subnav-entry-icon9 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 0 -255px;
    background-size: 28px auto;
}
.subnav-entry-icon10 {
     
    width: 28px;
    height: 28px;
    background-color: pink;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat 5px -285px;
    background-size: 28px auto;
}


/* 销售模块: */
.sales-box {
     
    background-color: #fff;
    border-top: 1px solid #bbb;
    margin: 4px;
}
.sales-hd {
     
    position: relative;
    height: 44px;
    border-bottom: 1px solid #ccc;
}
.sales-hd h2 {
     
    text-indent: -999px;
    overflow: hidden;
    position: relative;
}
.sales-hd h2::after {
     
    position: absolute;
    top: 8px;
    left: 20px;
    content: "";
    width: 79px;
    height: 15px;
    background:url(../images/hot.png) no-repeat 0 -20px;
    background-size: 79px auto;
}
.more {
     
    position: absolute;
    right: 5px;
    top: 0;
    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 #eee;
}
.row a:nth-child(1) {
     
    border-right: 1px solid #eee;
}
.row a img {
     
    width: 100%;
}

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, 
	initial-scale=1.0, maximum-scale=1.0, minimum-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/focus.jpg" alt="">
    div>
    
    <ul class="local-nav">
        <li>
            <a href="#" title="景点 玩乐">
                <span class="local-nav-icon1">span>
                <span>景点 玩乐span>
            a>
        li>
        <li>
            <a href="#"  title="景点 玩乐">
                <span class="local-nav-icon2">span>
                <span>周边游span>
            a>
        li>
        <li>
            <a href="#"  title="景点 玩乐">
                <span class="local-nav-icon3">span>
                <span>美食林span>
            a>
        li>
        <li>
            <a href="#"  title="景点 玩乐">
                <span class="local-nav-icon4">span>
                <span>一日游span>
            a>
        li>
        <li>
            <a href="#"  title="景点 玩乐">
                <span class="local-nav-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-icon1">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon2">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon3">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon4">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon5">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon6">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon7">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon8">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon9">span>
            <span>WIFI电话本span>
        a>li>
        <li><a href="#">
            <span class="subnav-entry-icon10">span>
            <span>WIFI电话本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>

前端移动Web第二天:Flex伸缩布局-携程首页案例_第1张图片

你可能感兴趣的:(一:移动WEB学习(看视频),html,css)