zoukankan      html  css  js  c++  java
  • 移动端弹性效果

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

    <body>

    <div class="wrap">

        <div class="header">header</div>

        <div class="main">

         弹性滚动区域

        </div>

        <div class="footer">footer</div>

    </div>

    </body>

    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 布局可解决

    <body>
    <div class="wrap">
          <div class="header">header</div>
          <div class="main">
           弹性滚动区域
          </div>
          <div class="footer">footer</div>
    </div>
    </body>
    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%;}

     

    那么剩下的主要问题是子容器高度超出父容器高度,子容器内容如何弹性滚动。

    .css{
    overflow:auto;/* winphone8和android4+ */
    -webkit-overflow-scrolling: touch; /* ios5+ */
    }

     

  • 相关阅读:
    HTTP本地代理服务器遇到的问题
    SMTP协议(Python实现)
    MOS_Chapter2_Process And Thread
    数据库系统概念Chapter2关系模型
    数据库系统概念 Chapter1介绍
    数据库系统概念第六版 答案
    python之sys.argv[1] IndexError: list index out of range
    计算机网络自顶向下之应用层套接字编程作业Web服务器
    罗技G302按一下效果是按两下
    第二部分1.3遍历dom
  • 原文地址:https://www.cnblogs.com/ranyonsue/p/5650606.html
Copyright © 2011-2022 走看看