ios解决输入框弹出后position:fixed失效问题_html/css_WEB-ITnose

php中文网
发布: 2016-06-24 11:32:27
原创
1854人浏览过

最近在使用amazeui进行仿app mobile web开发时遇到了讨论众多的position:fixed问题。position:fixed在安卓2.2以上已经实现,但是在ios8以下系统当小键盘激活时,会出现位置错位的问题。

如下图:

受到CSDN上刘华童鞋(http://my.csdn.net/liu__hua)的启发,找到了目前位置比较完美的解决方案。

<!DOCTYPE html><html lang="zh_cmn"><head><meta charset=utf-8 /><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" /><title></title><style>.head,.foot{position:fixed;left:0;height:38px;line-height:38px;width:100%;background-color:#99CC00;}.head{top:0;}.foot{bottom:0;}.main{position:fixed;top:38px;bottom:38px;width:100%;overflow:scroll;background-color:#BABABA;}</style></head><body><header class="head">顶部固定区域</header><article class="main"  id="wrapper">      <div>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>    <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>     <p>当内容欲出隐藏时,灰色区域可上下拖动</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>    <input type="text" value="" class="inputtext"> <br>        <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>  <input type="text" value="" class="inputtext"> <br>  <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>   <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>     <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>    <input type="text" value="" class="inputtext"> <br>     content <br>    content <br>    content <br>    content <br>    content <br>    content <br>    content <br>    content <br>    content <br>  </div></article><footer class="foot">底部固定区域</footer></body></html>
登录后复制

当小键盘出现时头部、底部自动跳到页面最顶端、最底端。键盘隐藏时又会固定在头部,底部。

内容转载于:http://blog.csdn.net/liu__hua/article/details/40106595

以作记录。

 

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号