本文引用出处: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{width:100%;}
.header,.footer{height:40px;line-height:40px;background-color:#D8D8D8;text-align:center;}
.header{position: absolute;top:0;left:0;width:100%;}
.footer{position: absolute;bottom:0;left:0;width:100%;}
.main{position:absolute;z-index:1;top:40px;left:0;bottom:40px;width: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;width: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;width:100%;}
position:fixed参考:https://css-tricks.com/snippets/css/a-guide-to-flexbox/

最新文章

  1. 通过WebStorm上传代码至github
  2. 关于json序列化循环引用导致出错
  3. PHP中CURL方法curl_setopt()函数的一些参数
  4. wcf http 代理
  5. 关于Windows窗口框架
  6. Web Api 上传图片,解决上传图片无格式
  7. HDU 3294 (Manacher) Girls&#39; research
  8. 类 .xml
  9. Matlab使用心得
  10. Fedora 21 设置开机启动脚本
  11. spring 定时器----quartz启动问题
  12. 在IE6里面当元素浮动后再设置margin那么就会产生双倍边距
  13. dotpeek的导出
  14. geyear和getfullyear的区别
  15. 使用Gulp进行代码压缩的步骤以及配置
  16. log4j日志记录级别是如何工作?
  17. leetcode — construct-binary-tree-from-preorder-and-inorder-traversal
  18. .NET领域最为流行的IOC框架之一Autofac WebAPI2使用Autofac实现IOC属性注入完美解决方案 AutoFac容器初步
  19. Ajax的异步与同步(async)
  20. Linux 命令详解(七)Systemd 入门教程:命令篇

热门文章

  1. 《Drools7.0.0.Final规则引擎教程》第3章 3.1 Hello World 实例
  2. 单项选择RadioButton和多项选择CheckBox的使用
  3. 自定义控件之TagGroup
  4. Kotlin 第一弹:自定义 ViewGroup 实现流式标签控件
  5. vue动态 设置类名
  6. HDU - 6433: H. Pow (简答题,输出大数)
  7. PS基础教程[7]如何为照片瘦身
  8. 重装Oracle时出现SID已存在问题的解决办法
  9. django的表与表之间的关系详细讲解
  10. 百度分享和bshare