zoukankan      html  css  js  c++  java
  • web页面在ios下不支持fixed可用absolute替代的方案

    本文引用出处:http://www.cnblogs.com/PeunZhang/p/3553020.html。

    对于 ios4 和 android2.2 以下不支持 position:fixed 的问题,有2种布局方法可以替代。

    布局一: 定义页面整体高度为100%,然后使用 position:absolute 布局可解决

    /*
    <!--absolute布局 [[ -->
    <body>
    <div class="wrap">
        <div class="header">header</div>
        <div class="main">
         弹性滚动区域
        </div>
        <div class="footer">footer</div>
    </div>
    </body>
    <!--absolute布局 ]] -->
    */
    html,body{height:100%;}
    .wrap{100%;}
    .header,.footer{height:40px;line-height:40px;background-color:#D8D8D8;text-align:center;}
    .header{position: absolute;top:0;left:0;100%;}
    .footer{position: absolute;bottom:0;left:0;100%;}
    .main{position:absolute;z-index:1;top:40px;left:0;bottom:40px;100%;}

    布局二: 定义页面整体高度为100%,然后使用 display:flex 布局可解决
    /*
    <!-- flex布局 [[ -->
    <body>
    <div class="wrap">
          <div class="header">header</div>
          <div class="main">
           弹性滚动区域
          </div>
          <div class="footer">footer</div>
    </div>
    </body>
    <!-- flex布局 ]] -->
    */
    html,body{height:100%;}
    .wrap{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;100%;height:100%;}
    .header,.footer{height:40px;line-height:40px;background-color:#D8D8D8;text-align:center;}
    .main{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;100%;}


    position:fixed参考:https://css-tricks.com/snippets/css/a-guide-to-flexbox/
  • 相关阅读:
    树链剖分( 洛谷P3384 )
    ZJOI 2015 诸神眷顾的幻想乡
    BZOJ 1002 [FJOI2007]轮状病毒
    洛谷 P1485 火枪打怪
    Luogu2860 [USACO06JAN]冗余路径Redundant Paths
    CF962F Simple Cycles Edges
    Luogu3605 [USACO17JAN]Promotion Counting晋升者计数
    Luogu2295 MICE
    CF341D Iahub and Xors
    CF617E XOR and Favorite Number
  • 原文地址:https://www.cnblogs.com/mjbin/p/4829938.html
Copyright © 2011-2022 走看看