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