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+ */
    }

     

  • 相关阅读:
    Markdown基本语法学习
    gauge自动化测试框架(二)
    初识gauge自动化测试框架
    火狐浏览器历代版本下载地址
    selenium + python实现截图并且保存图片
    Python搭建简易HTTP服务(3.x版本和2.x版本的)
    ((0.1+0.7)*10) = ?
    从apache mod_php到php-fpm[转]
    Web API文档生成工具apidoc
    微信支付获取 prepay id 偶尔失败问题【转】
  • 原文地址:https://www.cnblogs.com/ranyonsue/p/5650606.html
Copyright © 2011-2022 走看看